From 81a2f90a08f43e45cb700e6248c2baef0521e66a Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Wed, 28 Aug 2024 14:20:46 +0000 Subject: [PATCH] fix memory leak from global MeterProvider Kubernetes-commit: b42f8d32b52776b1331c4dc8d898aae92ca4dfe3 --- pkg/server/options/tracing.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/server/options/tracing.go b/pkg/server/options/tracing.go index d56e7df51..7be62fad0 100644 --- a/pkg/server/options/tracing.go +++ b/pkg/server/options/tracing.go @@ -23,7 +23,9 @@ import ( "net" "github.com/spf13/pflag" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/metric/noop" "go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/semconv/v1.12.0" "google.golang.org/grpc" @@ -48,6 +50,12 @@ var ( codecs = serializer.NewCodecFactory(cfgScheme) ) +func init() { + // Prevent memory leak from OTel metrics, which we don't use: + // https://github.com/open-telemetry/opentelemetry-go-contrib/issues/5190 + otel.SetMeterProvider(noop.NewMeterProvider()) +} + func init() { install.Install(cfgScheme) }