From d91ebffb30ec74fd0ebffbb32d7c969a2531411a Mon Sep 17 00:00:00 2001 From: SuperQ Date: Thu, 7 Dec 2023 15:50:21 +0100 Subject: [PATCH] Update deprecated otel functions Use new `noop.NewTracerProvider` function. Signed-off-by: SuperQ --- tracing/tracing.go | 3 ++- tracing/tracing_test.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tracing/tracing.go b/tracing/tracing.go index 6ff7dd4c0..d17540a91 100644 --- a/tracing/tracing.go +++ b/tracing/tracing.go @@ -32,6 +32,7 @@ import ( tracesdk "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.21.0" "go.opentelemetry.io/otel/trace" + "go.opentelemetry.io/otel/trace/noop" "google.golang.org/grpc/credentials" "github.com/prometheus/prometheus/config" @@ -87,7 +88,7 @@ func (m *Manager) ApplyConfig(cfg *config.Config) error { if cfg.TracingConfig.Endpoint == "" { m.config = cfg.TracingConfig m.shutdownFunc = nil - otel.SetTracerProvider(trace.NewNoopTracerProvider()) + otel.SetTracerProvider(noop.NewTracerProvider()) level.Info(m.logger).Log("msg", "Tracing provider uninstalled.") return nil } diff --git a/tracing/tracing_test.go b/tracing/tracing_test.go index f6b86ae62..b7996c610 100644 --- a/tracing/tracing_test.go +++ b/tracing/tracing_test.go @@ -20,7 +20,7 @@ import ( config_util "github.com/prometheus/common/config" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/trace" + "go.opentelemetry.io/otel/trace/noop" "github.com/prometheus/prometheus/config" ) @@ -105,7 +105,7 @@ func TestUninstallingTracerProvider(t *testing.T) { } require.NoError(t, m.ApplyConfig(&cfg)) - require.NotEqual(t, trace.NewNoopTracerProvider(), otel.GetTracerProvider()) + require.NotEqual(t, noop.NewTracerProvider(), otel.GetTracerProvider()) // Uninstall by passing empty config. cfg2 := config.Config{ @@ -114,7 +114,7 @@ func TestUninstallingTracerProvider(t *testing.T) { require.NoError(t, m.ApplyConfig(&cfg2)) // Make sure we get a no-op tracer provider after uninstallation. - require.Equal(t, trace.NewNoopTracerProvider(), otel.GetTracerProvider()) + require.Equal(t, noop.NewTracerProvider(), otel.GetTracerProvider()) } func TestTracerProviderShutdown(t *testing.T) {