-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[telemetrySettting] Create sampled Logger #8134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dmitryax
merged 35 commits into
open-telemetry:main
from
thousandeyes:develop/sampledLoggedCfg
Sep 29, 2023
Merged
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
4394496
Capability to configure sampledLogger in the exporterHelper
antonjim-te 3192d88
Capability to configure sampledLogger in the exporterHelper
antonjim-te 39f95e4
Improve documentation
antonjim-te 5295e11
Improve documentation
antonjim-te 9534fbb
Apply PR feedback
antonjim-te 56b71f3
Apply PR feedback
antonjim-te 5aec726
Apply PR feedback
antonjim-te 5d2cdeb
Merge main
antonjim-te 7ab0227
Fix linter
antonjim-te 9778c88
Add chloggen
antonjim-te b6ac5ac
Apply feedback. Describe sampled_logger config
antonjim-te 6c2051a
Merge master
antonjim-te f53561a
Merge branch 'open-telemetry:main' into develop/sampledLoggedCfg
antonjim-te 310b747
Merge master
antonjim-te 9540c55
Create a extra sampled logger as part of the telemetry settings
antonjim-te 20536a1
Review PR
antonjim-te 0b60ef8
Apply feedback from @mx-psi . Create the sampledLogger the first time…
antonjim-te 0add644
Add telemetry test
antonjim-te 37fcef7
Update variable name
antonjim-te 70f05d8
Update variable name
antonjim-te a5d054b
Merge branch 'main' into develop/sampledLoggedCfg
antonjim-te 868041f
Fix merge commit
antonjim-te 8a321ac
Apply @dmitryax feedback. Keep Sampling config in general logger
antonjim-te 0cb309c
review PR
antonjim-te bc250fb
Review PR
antonjim-te 7180926
Update default sampling logger configuration in the telemetry configu…
antonjim-te 15b3b42
Merge branch 'main' into develop/sampledLoggedCfg
antonjim-te 409f6ff
Fix merge
antonjim-te 66fa58e
Fix linter
antonjim-te 4b84a00
Apply @dmitryax feedback
antonjim-te fcd2b83
Apply @dmitryax feedback
antonjim-te ce3776a
Apply @dmitryax feedback
antonjim-te bce885d
apply @jpkrohling feedback
antonjim-te f9ca8a7
apply @jpkrohling feedback
antonjim-te 8c3cddd
apply feedback
antonjim-te File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: service/telemetry exporter/exporterhelper | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Enable sampling logging by default and apply it to all components." | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [8134] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: The sampled logger configuration can be disabled easily by setting the `service::telemetry::logs::sampling::enabled` to `false`. | ||
|
||
|
||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package telemetry | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
|
||
"go.opentelemetry.io/collector/config/configtelemetry" | ||
) | ||
|
||
func TestTelemetryConfiguration(t *testing.T) { | ||
dmitryax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tests := []struct { | ||
name string | ||
cfg *Config | ||
success bool | ||
}{ | ||
{ | ||
name: "Valid config", | ||
cfg: &Config{ | ||
Logs: LogsConfig{ | ||
Level: zapcore.DebugLevel, | ||
Encoding: "console", | ||
}, | ||
Metrics: MetricsConfig{ | ||
Level: configtelemetry.LevelBasic, | ||
Address: "127.0.0.1:3333", | ||
}, | ||
}, | ||
success: true, | ||
}, | ||
{ | ||
name: "Invalid config", | ||
cfg: &Config{ | ||
Logs: LogsConfig{ | ||
Level: zapcore.DebugLevel, | ||
}, | ||
Metrics: MetricsConfig{ | ||
Level: configtelemetry.LevelBasic, | ||
Address: "127.0.0.1:3333", | ||
}, | ||
}, | ||
success: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
telemetry, err := New(context.Background(), Settings{ZapOptions: []zap.Option{}}, *tt.cfg) | ||
if tt.success { | ||
assert.NoError(t, err) | ||
assert.NotNil(t, telemetry) | ||
} else { | ||
assert.Error(t, err) | ||
assert.Nil(t, telemetry) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestSampledLogger(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
cfg *Config | ||
}{ | ||
{ | ||
name: "Default sampling", | ||
cfg: &Config{ | ||
Logs: LogsConfig{ | ||
Encoding: "console", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Custom sampling", | ||
cfg: &Config{ | ||
Logs: LogsConfig{ | ||
Level: zapcore.DebugLevel, | ||
Encoding: "console", | ||
Sampling: &LogsSamplingConfig{ | ||
Enabled: true, | ||
Tick: 1 * time.Second, | ||
Initial: 100, | ||
Thereafter: 100, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Disable sampling", | ||
cfg: &Config{ | ||
Logs: LogsConfig{ | ||
Level: zapcore.DebugLevel, | ||
Encoding: "console", | ||
Sampling: &LogsSamplingConfig{ | ||
Enabled: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
telemetry, err := New(context.Background(), Settings{ZapOptions: []zap.Option{}}, *tt.cfg) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, telemetry) | ||
assert.NotNil(t, telemetry.Logger()) | ||
}) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.