From b654e2b1b476dde768b1dac3ff9d1e0265848d8f Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Tue, 18 Apr 2023 10:30:03 +0200 Subject: [PATCH] put otel meter for http/grpc behind a FF (#202) --- config/configgrpc/configgrpc.go | 6 +++++- config/confighttp/confighttp.go | 12 +++++++++--- internal/obsreportconfig/obsreportconfig.go | 8 ++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 68e79942a25..20469d705bb 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -45,6 +45,7 @@ import ( "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/config/internal" "go.opentelemetry.io/collector/extension/auth" + "go.opentelemetry.io/collector/internal/obsreportconfig" ) var errMetadataNotFound = errors.New("no request metadata found") @@ -260,10 +261,13 @@ func (gcs *GRPCClientSettings) toDialOptions(host component.Host, settings compo otelOpts := []otelgrpc.Option{ otelgrpc.WithTracerProvider(settings.TracerProvider), - otelgrpc.WithMeterProvider(settings.MeterProvider), otelgrpc.WithPropagators(otel.GetTextMapPropagator()), } + if obsreportconfig.EnableHighCardinalityMetricsfeatureGate.IsEnabled() { + otelOpts = append(otelOpts, otelgrpc.WithMeterProvider(settings.MeterProvider)) + } + // Enable OpenTelemetry observability plugin. opts = append(opts, grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor(otelOpts...))) opts = append(opts, grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(otelOpts...))) diff --git a/config/confighttp/confighttp.go b/config/confighttp/confighttp.go index 99a86d6bd64..88128e84881 100644 --- a/config/confighttp/confighttp.go +++ b/config/confighttp/confighttp.go @@ -33,6 +33,7 @@ import ( "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/config/internal" "go.opentelemetry.io/collector/extension/auth" + "go.opentelemetry.io/collector/internal/obsreportconfig" ) const headerContentEncoding = "Content-Encoding" @@ -143,11 +144,16 @@ func (hcs *HTTPClientSettings) ToClient(host component.Host, settings component. } // wrapping http transport with otelhttp transport to enable otel instrumenetation if settings.TracerProvider != nil && settings.MeterProvider != nil { - clientTransport = otelhttp.NewTransport( - clientTransport, + otelOpts := []otelhttp.Option{ otelhttp.WithTracerProvider(settings.TracerProvider), - otelhttp.WithMeterProvider(settings.MeterProvider), otelhttp.WithPropagators(otel.GetTextMapPropagator()), + } + if obsreportconfig.EnableHighCardinalityMetricsfeatureGate.IsEnabled() { + otelOpts = append(otelOpts, otelhttp.WithMeterProvider(settings.MeterProvider)) + } + clientTransport = otelhttp.NewTransport( + clientTransport, + otelOpts..., ) } diff --git a/internal/obsreportconfig/obsreportconfig.go b/internal/obsreportconfig/obsreportconfig.go index c4e03edf0bb..f090fac131d 100644 --- a/internal/obsreportconfig/obsreportconfig.go +++ b/internal/obsreportconfig/obsreportconfig.go @@ -31,6 +31,14 @@ var UseOtelForInternalMetricsfeatureGate = featuregate.GlobalRegistry().MustRegi featuregate.StageAlpha, featuregate.WithRegisterDescription("controls whether the collector uses OpenTelemetry for internal metrics")) +// EnableHighCardinalityMetricsfeatureGate is the feature gate that controls whether the collecor should enable +// potentially high cardinality metrics. +var EnableHighCardinalityMetricsfeatureGate = featuregate.GlobalRegistry().MustRegister( + "telemetry.enableHighCardinalityMetrics", + featuregate.StageAlpha, + featuregate.WithRegisterDescription("controls whether the collecor should enable potentially high"+ + "cardinality metrics.")) + // AllViews returns all the OpenCensus views requires by obsreport package. func AllViews(level configtelemetry.Level) []*view.View { if level == configtelemetry.LevelNone {