From 39f95e42a9332e67439fa4b16e0e5c690f0f0edb Mon Sep 17 00:00:00 2001 From: Antonio Jimenez Date: Wed, 26 Jul 2023 15:55:23 +0200 Subject: [PATCH] Improve documentation --- exporter/exporterhelper/README.md | 2 +- exporter/exporterhelper/common.go | 4 ++-- exporter/exporterhelper/queued_retry.go | 6 +----- exporter/otlphttpexporter/README.md | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/exporter/exporterhelper/README.md b/exporter/exporterhelper/README.md index 70ba05706f2..267e6759667 100644 --- a/exporter/exporterhelper/README.md +++ b/exporter/exporterhelper/README.md @@ -24,7 +24,7 @@ The following configuration options can be modified: [the batch processor](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor) is used, the metric `batch_send_size` can be used for estimation) - `timeout` (default = 5s): Time to wait per individual attempt to send data to a backend -- `sampled_logger`: Samples logging messages, which caps the CPU and I/O load of logging while keeping a representative subset of your logs. +- `sampled_logger`: Enables/disables sampling of logging messages, which caps the CPU and I/O load of logging while keeping a representative subset of your logs. - `enabled` (default = true) The `initial_interval`, `max_interval`, `max_elapsed_time`, and `timeout` options accept diff --git a/exporter/exporterhelper/common.go b/exporter/exporterhelper/common.go index a39ec91e370..a8781f57b16 100644 --- a/exporter/exporterhelper/common.go +++ b/exporter/exporterhelper/common.go @@ -27,11 +27,11 @@ func NewDefaultTimeoutSettings() TimeoutSettings { } } -// SampledLoggerSettings samples logging messages, which caps the CPU and I/O load of logging while keeping a +// SampledLoggerSettings Configure the logger sampler, which caps the CPU and I/O load of logging while keeping a // representative subset of your logs. // Its purpose is to balance between the need for comprehensive logging and the potential performance impact of logging too much data. type SampledLoggerSettings struct { - // Enable the sampledLogger + // Enable/disable the sampledLogger Enabled bool `mapstructure:"enabled"` } diff --git a/exporter/exporterhelper/queued_retry.go b/exporter/exporterhelper/queued_retry.go index 5c852d76156..715bac50048 100644 --- a/exporter/exporterhelper/queued_retry.go +++ b/exporter/exporterhelper/queued_retry.go @@ -267,15 +267,11 @@ func NewDefaultRetrySettings() RetrySettings { } func createSampledLogger(logger *zap.Logger, lCfg SampledLoggerSettings) *zap.Logger { - if logger.Core().Enabled(zapcore.DebugLevel) { + if !lCfg.Enabled || logger.Core().Enabled(zapcore.DebugLevel) { // Debugging is enabled. Don't do any sampling. return logger } - if !lCfg.Enabled { - return logger - } - // Create a logger that samples all messages to 1 per 10 seconds initially, // and 1/100 of messages after that. opts := zap.WrapCore(func(core zapcore.Core) zapcore.Core { diff --git a/exporter/otlphttpexporter/README.md b/exporter/otlphttpexporter/README.md index 73d3c776d45..58c476d7349 100644 --- a/exporter/otlphttpexporter/README.md +++ b/exporter/otlphttpexporter/README.md @@ -31,7 +31,7 @@ The following settings can be optionally configured: - `timeout` (default = 30s): HTTP request time limit. For details see https://golang.org/pkg/net/http/#Client - `read_buffer_size` (default = 0): ReadBufferSize for HTTP client. - `write_buffer_size` (default = 512 * 1024): WriteBufferSize for HTTP client. -- `sampled_logger`: Samples logging messages, which caps the CPU and I/O load of logging while keeping a representative subset of your logs. +- `sampled_logger`: Enables/disables sampling of logging messages, which caps the CPU and I/O load of logging while keeping a representative subset of your logs. - `enabled` (default = true) Example: