Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put otel meter for http/grpc behind a FF #202

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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...)))
Expand Down
12 changes: 9 additions & 3 deletions config/confighttp/confighttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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...,
)
}

Expand Down
8 changes: 8 additions & 0 deletions internal/obsreportconfig/obsreportconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about renaming this as "enableRPCMetrics" or something like that, to be more specific about what this is gating?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was coming from the issue i opened against the collector open-telemetry#7517 (comment) given there may be some more high cardinality metrics like this in the future.

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 {
Expand Down
2 changes: 1 addition & 1 deletion service/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,4 @@ func batchViews() []sdkmetric.View {
}},
),
}
}
}