Skip to content

Commit 4b84a00

Browse files
committed
Apply @dmitryax feedback
1 parent 66fa58e commit 4b84a00

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

.chloggen/SampledLoggerTelemetry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ change_type: enhancement
77
component: service/telemetry exporter/exporterhelper
88

99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10-
note: "Update default sampling logger configuration in the telemetry configuration."
10+
note: "Enable sampling logging by default and apply it to all components."
1111

1212
# One or more tracking issues or pull requests related to the change
1313
issues: [8134]

otelcol/unmarshaler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func unmarshal(v *confmap.Conf, factories Factories) (*configSettings, error) {
4848
Encoding: "console",
4949
Sampling: &telemetry.LogsSamplingConfig{
5050
Enabled: true,
51-
Tick: 1 * time.Second,
51+
Tick: 10 * time.Second,
5252
Initial: 10,
5353
Thereafter: 100,
5454
},

otelcol/unmarshaler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestUnmarshalEmptyAllSections(t *testing.T) {
4747
Encoding: "console",
4848
Sampling: &telemetry.LogsSamplingConfig{
4949
Enabled: true,
50-
Tick: 1 * time.Second,
50+
Tick: 10 * time.Second,
5151
Initial: 10,
5252
Thereafter: 100,
5353
},

service/telemetry/config.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,15 @@ type LogsConfig struct {
9999
// global CPU and I/O load that logging puts on your process while attempting
100100
// to preserve a representative subset of your logs.
101101
type LogsSamplingConfig struct {
102-
Enabled bool `mapstructure:"enabled"`
103-
Tick time.Duration `mapstructure:"tick"`
104-
Initial int `mapstructure:"initial"`
105-
Thereafter int `mapstructure:"thereafter"`
102+
// Enabled enable sampling logging
103+
Enabled bool `mapstructure:"enabled"`
104+
// Tick represents the interval in seconds that the logger apply each sampling.
105+
Tick time.Duration `mapstructure:"tick"`
106+
// Initial represents the first M messages logged each Tick.
107+
Initial int `mapstructure:"initial"`
108+
// Thereafter represents the N messages logged after Initial and the rest are dropped, during each Tick.
109+
// If Thereafter is zero, the Core will drop all log entries after the first M messages each Tick.
110+
Thereafter int `mapstructure:"thereafter"`
106111
}
107112

108113
// MetricsConfig exposes the common Telemetry configuration for one component.

service/telemetry/telemetry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ func newLogger(cfg LogsConfig, options []zap.Option) (*zap.Logger, error) {
8585
}
8686

8787
func newSampledLogger(logger *zap.Logger, sc *LogsSamplingConfig) *zap.Logger {
88-
// Create a logger that samples all messages to sc.Tick per second initially,
89-
// and sc.Initial/sc.Thereafter of messages after that.
88+
// Create a logger that samples every Nth message after the first M messages every S seconds
89+
// where N = sc.Thereafter, M = sc.Initial, S = sc.Tick.
9090
opts := zap.WrapCore(func(core zapcore.Core) zapcore.Core {
9191
return zapcore.NewSamplerWithOptions(
9292
core,

0 commit comments

Comments
 (0)