From e86ada135a1e777264a8d658615ecafa9914f531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Wed, 27 Nov 2024 18:17:04 +0100 Subject: [PATCH] [chore][exporter/loadbalancing] Add debug statements after failed export operation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juraci Paixão Kröhling --- exporter/loadbalancingexporter/factory.go | 10 +++++----- exporter/loadbalancingexporter/log_exporter.go | 4 ++++ exporter/loadbalancingexporter/metrics_exporter.go | 4 ++++ exporter/loadbalancingexporter/trace_exporter.go | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/exporter/loadbalancingexporter/factory.go b/exporter/loadbalancingexporter/factory.go index 1e10395162c4..864acf3a8d2e 100644 --- a/exporter/loadbalancingexporter/factory.go +++ b/exporter/loadbalancingexporter/factory.go @@ -83,22 +83,22 @@ func buildExporterResilienceOptions(options []exporterhelper.Option, cfg *Config func createTracesExporter(ctx context.Context, params exporter.Settings, cfg component.Config) (exporter.Traces, error) { c := cfg.(*Config) - exporter, err := newTracesExporter(params, cfg) + exp, err := newTracesExporter(params, cfg) if err != nil { return nil, fmt.Errorf("cannot configure loadbalancing traces exporter: %w", err) } options := []exporterhelper.Option{ - exporterhelper.WithStart(exporter.Start), - exporterhelper.WithShutdown(exporter.Shutdown), - exporterhelper.WithCapabilities(exporter.Capabilities()), + exporterhelper.WithStart(exp.Start), + exporterhelper.WithShutdown(exp.Shutdown), + exporterhelper.WithCapabilities(exp.Capabilities()), } return exporterhelper.NewTraces( ctx, params, cfg, - exporter.ConsumeTraces, + exp.ConsumeTraces, buildExporterResilienceOptions(options, c)..., ) } diff --git a/exporter/loadbalancingexporter/log_exporter.go b/exporter/loadbalancingexporter/log_exporter.go index 2d1385b76e34..efa5e23bc429 100644 --- a/exporter/loadbalancingexporter/log_exporter.go +++ b/exporter/loadbalancingexporter/log_exporter.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/otel/metric" "go.uber.org/multierr" + "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal" @@ -27,6 +28,7 @@ var _ exporter.Logs = (*logExporterImp)(nil) type logExporterImp struct { loadBalancer *loadBalancer + logger *zap.Logger started bool shutdownWg sync.WaitGroup telemetry *metadata.TelemetryBuilder @@ -54,6 +56,7 @@ func newLogsExporter(params exporter.Settings, cfg component.Config) (*logExport return &logExporterImp{ loadBalancer: lb, telemetry: telemetry, + logger: params.Logger, }, nil } @@ -112,6 +115,7 @@ func (e *logExporterImp) consumeLog(ctx context.Context, ld plog.Logs) error { e.telemetry.LoadbalancerBackendOutcome.Add(ctx, 1, metric.WithAttributeSet(le.successAttr)) } else { e.telemetry.LoadbalancerBackendOutcome.Add(ctx, 1, metric.WithAttributeSet(le.failureAttr)) + e.logger.Debug("failed to export log", zap.Error(err)) } return err diff --git a/exporter/loadbalancingexporter/metrics_exporter.go b/exporter/loadbalancingexporter/metrics_exporter.go index 45bef77149e3..fb61bd84ae7f 100644 --- a/exporter/loadbalancingexporter/metrics_exporter.go +++ b/exporter/loadbalancingexporter/metrics_exporter.go @@ -18,6 +18,7 @@ import ( conventions "go.opentelemetry.io/collector/semconv/v1.27.0" "go.opentelemetry.io/otel/metric" "go.uber.org/multierr" + "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics" @@ -30,6 +31,7 @@ type metricExporterImp struct { loadBalancer *loadBalancer routingKey routingKey + logger *zap.Logger stopped bool shutdownWg sync.WaitGroup telemetry *metadata.TelemetryBuilder @@ -57,6 +59,7 @@ func newMetricsExporter(params exporter.Settings, cfg component.Config) (*metric loadBalancer: lb, routingKey: svcRouting, telemetry: telemetry, + logger: params.Logger, } switch cfg.(*Config).RoutingKey { @@ -142,6 +145,7 @@ func (e *metricExporterImp) ConsumeMetrics(ctx context.Context, md pmetric.Metri e.telemetry.LoadbalancerBackendOutcome.Add(ctx, 1, metric.WithAttributeSet(exp.successAttr)) } else { e.telemetry.LoadbalancerBackendOutcome.Add(ctx, 1, metric.WithAttributeSet(exp.failureAttr)) + e.logger.Debug("failed to export metrics", zap.Error(err)) } } diff --git a/exporter/loadbalancingexporter/trace_exporter.go b/exporter/loadbalancingexporter/trace_exporter.go index e6fb9647d977..608627a732f9 100644 --- a/exporter/loadbalancingexporter/trace_exporter.go +++ b/exporter/loadbalancingexporter/trace_exporter.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/otel/metric" "go.uber.org/multierr" + "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal" @@ -30,6 +31,7 @@ type traceExporterImp struct { loadBalancer *loadBalancer routingKey routingKey + logger *zap.Logger stopped bool shutdownWg sync.WaitGroup telemetry *metadata.TelemetryBuilder @@ -59,6 +61,7 @@ func newTracesExporter(params exporter.Settings, cfg component.Config) (*traceEx loadBalancer: lb, routingKey: traceIDRouting, telemetry: telemetry, + logger: params.Logger, } switch cfg.(*Config).RoutingKey { @@ -127,6 +130,7 @@ func (e *traceExporterImp) ConsumeTraces(ctx context.Context, td ptrace.Traces) e.telemetry.LoadbalancerBackendOutcome.Add(ctx, 1, metric.WithAttributeSet(exp.successAttr)) } else { e.telemetry.LoadbalancerBackendOutcome.Add(ctx, 1, metric.WithAttributeSet(exp.failureAttr)) + e.logger.Debug("failed to export traces", zap.Error(err)) } }