From 6dd265d9494a0bb714873cfdf6d39809236eb6d5 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 5 Jul 2024 10:25:48 +0300 Subject: [PATCH] [#12] tracing: Optimize noop exporter Signed-off-by: Evgenii Stratonikov --- tracing/setup.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracing/setup.go b/tracing/setup.go index 0d20478..2fca75b 100644 --- a/tracing/setup.go +++ b/tracing/setup.go @@ -3,7 +3,6 @@ package tracing import ( "context" "fmt" - "io" "sync" "sync/atomic" @@ -12,6 +11,7 @@ import ( "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" + "go.opentelemetry.io/otel/sdk/trace/tracetest" semconv "go.opentelemetry.io/otel/semconv/v1.17.0" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/noop" @@ -133,7 +133,7 @@ func getExporter(ctx context.Context, cfg *Config) (sdktrace.SpanExporter, error case StdoutExporter: return stdouttrace.New() case NoOpExporter: - return stdouttrace.New(stdouttrace.WithWriter(io.Discard)) + return tracetest.NewNoopExporter(), nil case OTLPgRPCExporter: return otlptracegrpc.New(ctx, otlptracegrpc.WithEndpoint(cfg.Endpoint), otlptracegrpc.WithInsecure()) }