From b34aaaa0f113668278575e58ba59bb88a91a17df Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 23 May 2024 07:37:37 -0700 Subject: [PATCH] [chore] Remove unused ocRegistry, no longer used --- service/telemetry.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/service/telemetry.go b/service/telemetry.go index 365ea3d23c5..c2a67c7f16f 100644 --- a/service/telemetry.go +++ b/service/telemetry.go @@ -9,11 +9,9 @@ import ( "net/http" "strconv" - ocmetric "go.opencensus.io/metric" - "go.opencensus.io/metric/metricproducer" "go.opentelemetry.io/contrib/config" "go.opentelemetry.io/otel/metric" - noopmetric "go.opentelemetry.io/otel/metric/noop" + "go.opentelemetry.io/otel/metric/noop" sdkmetric "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/resource" "go.uber.org/multierr" @@ -31,8 +29,7 @@ const ( type meterProvider struct { *sdkmetric.MeterProvider - ocRegistry *ocmetric.Registry - servers []*http.Server + servers []*http.Server } type meterProviderSettings struct { @@ -43,7 +40,7 @@ type meterProviderSettings struct { func newMeterProvider(set meterProviderSettings, disableHighCardinality bool) (metric.MeterProvider, error) { if set.cfg.Level == configtelemetry.LevelNone || (set.cfg.Address == "" && len(set.cfg.Readers) == 0) { - return noopmetric.NewMeterProvider(), nil + return noop.NewMeterProvider(), nil } if len(set.cfg.Address) != 0 { @@ -70,12 +67,8 @@ func newMeterProvider(set meterProviderSettings, disableHighCardinality bool) (m }) } - mp := &meterProvider{ - // Initialize the ocRegistry, still used by the process metrics. - ocRegistry: ocmetric.NewRegistry(), - } - metricproducer.GlobalManager().AddProducer(mp.ocRegistry) - opts := []sdkmetric.Option{} + mp := &meterProvider{} + var opts []sdkmetric.Option for _, reader := range set.cfg.Readers { // https://github.com/open-telemetry/opentelemetry-collector/issues/8045 r, server, err := proctelemetry.InitMetricReader(context.Background(), reader, set.asyncErrorChannel) @@ -111,8 +104,6 @@ func (mp *meterProvider) LogAboutServers(logger *zap.Logger, cfg telemetry.Metri // Shutdown the meter provider and all the associated resources. // The type signature of this method matches that of the sdkmetric.MeterProvider. func (mp *meterProvider) Shutdown(ctx context.Context) error { - metricproducer.GlobalManager().DeleteProducer(mp.ocRegistry) - var errs error for _, server := range mp.servers { if server != nil {