Skip to content
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

[chore][exporter/loadbalancing] Add debug statements after failed export operation #36575

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions exporter/loadbalancingexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...,
)
}
Expand Down
4 changes: 4 additions & 0 deletions exporter/loadbalancingexporter/log_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -54,6 +56,7 @@ func newLogsExporter(params exporter.Settings, cfg component.Config) (*logExport
return &logExporterImp{
loadBalancer: lb,
telemetry: telemetry,
logger: params.Logger,
}, nil
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions exporter/loadbalancingexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -30,6 +31,7 @@ type metricExporterImp struct {
loadBalancer *loadBalancer
routingKey routingKey

logger *zap.Logger
stopped bool
shutdownWg sync.WaitGroup
telemetry *metadata.TelemetryBuilder
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
}

Expand Down
4 changes: 4 additions & 0 deletions exporter/loadbalancingexporter/trace_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -30,6 +31,7 @@ type traceExporterImp struct {
loadBalancer *loadBalancer
routingKey routingKey

logger *zap.Logger
stopped bool
shutdownWg sync.WaitGroup
telemetry *metadata.TelemetryBuilder
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
}

Expand Down
Loading