From 89f881987c0bfff7f3089b127bccf36578700d75 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Thu, 31 Jul 2025 17:44:14 +0800 Subject: [PATCH 1/7] Deprecate telemetry.disableHighCardinalityMetrics --- .chloggen/service-deprecate-featuregate.yaml | 27 ++++++++++++++++++++ service/service.go | 8 +++--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 .chloggen/service-deprecate-featuregate.yaml diff --git a/.chloggen/service-deprecate-featuregate.yaml b/.chloggen/service-deprecate-featuregate.yaml new file mode 100644 index 000000000000..232c514dfbe5 --- /dev/null +++ b/.chloggen/service-deprecate-featuregate.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: service + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: The `telemetry.disableHighCardinalityMetrics` feature gate is deprecated + +# One or more tracking issues or pull requests related to the change +issues: [13537] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + The feature gate is now deprecated since metric views can be configured. + The gate will be removed in v1.40.0. + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/service/service.go b/service/service.go index 3983e7989016..31f2d55dc4e1 100644 --- a/service/service.go +++ b/service/service.go @@ -49,9 +49,11 @@ import ( // potentially high cardinality metrics. The gate will be removed when the collector allows for view configuration. var disableHighCardinalityMetricsFeatureGate = featuregate.GlobalRegistry().MustRegister( "telemetry.disableHighCardinalityMetrics", - featuregate.StageAlpha, - featuregate.WithRegisterDescription("controls whether the collector should enable potentially high"+ - "cardinality metrics. The gate will be removed when the collector allows for view configuration.")) + featuregate.StageDeprecated, + featuregate.WithRegisterToVersion("1.39.0"), + featuregate.WithRegisterDescription( + "Controls whether the collector should enable potentially high "+ + "cardinality metrics. Deprecated, configure service::telemetry::metrics::views instead.")) // ModuleInfo describes the Go module for a particular component. type ModuleInfo = moduleinfo.ModuleInfo From db8714ba0926064c5e319b04521fe10119db342f Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Fri, 1 Aug 2025 08:40:37 +0800 Subject: [PATCH 2/7] Remove references to the feature gate Now that the feature gate is deprecated it cannot be enabled, so we can remove all references. Moreover, the view that was excluding high cardinality attributes from otelhttp and otelgrpc was broken, as the attributes were renamed in the instrumentation. --- service/service.go | 48 ++----------------------------- service/telemetry/metrics_test.go | 16 ++++------- 2 files changed, 8 insertions(+), 56 deletions(-) diff --git a/service/service.go b/service/service.go index 31f2d55dc4e1..48f099ffb089 100644 --- a/service/service.go +++ b/service/service.go @@ -17,7 +17,6 @@ import ( "go.opentelemetry.io/otel/metric" noopmetric "go.opentelemetry.io/otel/metric/noop" sdkresource "go.opentelemetry.io/otel/sdk/resource" - semconv118 "go.opentelemetry.io/otel/semconv/v1.18.0" semconv "go.opentelemetry.io/otel/semconv/v1.26.0" nooptrace "go.opentelemetry.io/otel/trace/noop" "go.uber.org/multierr" @@ -45,9 +44,8 @@ import ( "go.opentelemetry.io/collector/service/telemetry" ) -// disableHighCardinalityMetricsFeatureGate is the feature gate that controls whether the collector should enable -// potentially high cardinality metrics. The gate will be removed when the collector allows for view configuration. -var disableHighCardinalityMetricsFeatureGate = featuregate.GlobalRegistry().MustRegister( +// This feature gate is deprecated and will be removed in 1.40.0. Views can now be configured. +var _ = featuregate.GlobalRegistry().MustRegister( "telemetry.disableHighCardinalityMetrics", featuregate.StageDeprecated, featuregate.WithRegisterToVersion("1.39.0"), @@ -136,12 +134,7 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) { sch := semconv.SchemaURL mpConfig := &cfg.Telemetry.Metrics.MeterProvider - - if mpConfig.Views != nil { - if disableHighCardinalityMetricsFeatureGate.IsEnabled() { - return nil, errors.New("telemetry.disableHighCardinalityMetrics gate is incompatible with service::telemetry::metrics::views") - } - } else { + if mpConfig.Views == nil { mpConfig.Views = configureViews(cfg.Telemetry.Metrics.Level) } @@ -435,41 +428,6 @@ func configureViews(level configtelemetry.Level) []config.View { ) } - // Make sure to add the AttributeKeys view after the AggregationDrop view: - // Only the first view outputting a given metric identity is actually used, so placing the - // AttributeKeys view first would never drop the metrics regadless of level. - if disableHighCardinalityMetricsFeatureGate.IsEnabled() { - views = append(views, []config.View{ - { - Selector: &config.ViewSelector{ - MeterName: ptr("go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"), - }, - Stream: &config.ViewStream{ - AttributeKeys: &config.IncludeExclude{ - Excluded: []string{ - string(semconv118.NetSockPeerAddrKey), - string(semconv118.NetSockPeerPortKey), - string(semconv118.NetSockPeerNameKey), - }, - }, - }, - }, - { - Selector: &config.ViewSelector{ - MeterName: ptr("go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"), - }, - Stream: &config.ViewStream{ - AttributeKeys: &config.IncludeExclude{ - Excluded: []string{ - string(semconv118.NetHostNameKey), - string(semconv118.NetHostPortKey), - }, - }, - }, - }, - }...) - } - // otel-arrow library metrics // See https://github.com/open-telemetry/otel-arrow/blob/c39257/pkg/otel/arrow_record/consumer.go#L174-L176 if level < configtelemetry.LevelNormal { diff --git a/service/telemetry/metrics_test.go b/service/telemetry/metrics_test.go index 3ea2a12d60fc..cccd532ef8ec 100644 --- a/service/telemetry/metrics_test.go +++ b/service/telemetry/metrics_test.go @@ -17,7 +17,7 @@ import ( config "go.opentelemetry.io/contrib/otelconf/v0.3.0" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - semconv "go.opentelemetry.io/otel/semconv/v1.18.0" + semconv "go.opentelemetry.io/otel/semconv/v1.34.0" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/service/internal/promtest" @@ -57,9 +57,7 @@ func TestTelemetryInit(t *testing.T) { metricPrefix + grpcPrefix + counterName: { value: 11, labels: map[string]string{ - "net_sock_peer_addr": "", - "net_sock_peer_name": "", - "net_sock_peer_port": "", + "rpc_system": "grpc", "service_name": "otelcol", "service_version": "latest", "service_instance_id": testInstanceID, @@ -68,8 +66,7 @@ func TestTelemetryInit(t *testing.T) { metricPrefix + httpPrefix + counterName: { value: 10, labels: map[string]string{ - "net_host_name": "", - "net_host_port": "", + "http_request_method": "GET", "service_name": "otelcol", "service_version": "latest", "service_instance_id": testInstanceID, @@ -167,16 +164,13 @@ func createTestMetrics(t *testing.T, mp metric.MeterProvider) { grpcExampleCounter, err := mp.Meter("go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc").Int64Counter(metricPrefix + grpcPrefix + counterName) require.NoError(t, err) grpcExampleCounter.Add(context.Background(), 11, metric.WithAttributeSet(attribute.NewSet( - attribute.String(string(semconv.NetSockPeerAddrKey), ""), - attribute.String(string(semconv.NetSockPeerPortKey), ""), - attribute.String(string(semconv.NetSockPeerNameKey), ""), + attribute.String(string(semconv.RPCSystemKey), "grpc"), ))) httpExampleCounter, err := mp.Meter("go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp").Int64Counter(metricPrefix + httpPrefix + counterName) require.NoError(t, err) httpExampleCounter.Add(context.Background(), 10, metric.WithAttributeSet(attribute.NewSet( - attribute.String(string(semconv.NetHostNameKey), ""), - attribute.String(string(semconv.NetHostPortKey), ""), + attribute.String(string(semconv.HTTPRequestMethodKey), "GET"), ))) } From 69b1c355c947e38793e5501d5b8c9828d2e9cef4 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Fri, 1 Aug 2025 08:50:44 +0800 Subject: [PATCH 3/7] Use a consistent semconv version --- service/telemetry/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/telemetry/metrics_test.go b/service/telemetry/metrics_test.go index cccd532ef8ec..d3642a5789e3 100644 --- a/service/telemetry/metrics_test.go +++ b/service/telemetry/metrics_test.go @@ -17,7 +17,7 @@ import ( config "go.opentelemetry.io/contrib/otelconf/v0.3.0" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - semconv "go.opentelemetry.io/otel/semconv/v1.34.0" + semconv "go.opentelemetry.io/otel/semconv/v1.26.0" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/service/internal/promtest" From 7a46630212fc488e252cf789327f257a5a722238 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Fri, 1 Aug 2025 15:27:00 +0800 Subject: [PATCH 4/7] Apply suggestions from code review --- .chloggen/service-deprecate-featuregate.yaml | 2 +- service/service.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.chloggen/service-deprecate-featuregate.yaml b/.chloggen/service-deprecate-featuregate.yaml index 232c514dfbe5..8618b9e790eb 100644 --- a/.chloggen/service-deprecate-featuregate.yaml +++ b/.chloggen/service-deprecate-featuregate.yaml @@ -17,7 +17,7 @@ issues: [13537] # Use pipe (|) for multiline entries. subtext: | The feature gate is now deprecated since metric views can be configured. - The gate will be removed in v1.40.0. + The gate will be removed in v0.134.0. # Optional: The change log or logs in which this entry should be included. # e.g. '[user]' or '[user, api]' diff --git a/service/service.go b/service/service.go index 48f099ffb089..b2af24c0dfd8 100644 --- a/service/service.go +++ b/service/service.go @@ -48,7 +48,7 @@ import ( var _ = featuregate.GlobalRegistry().MustRegister( "telemetry.disableHighCardinalityMetrics", featuregate.StageDeprecated, - featuregate.WithRegisterToVersion("1.39.0"), + featuregate.WithRegisterToVersion("0.133.0"), featuregate.WithRegisterDescription( "Controls whether the collector should enable potentially high "+ "cardinality metrics. Deprecated, configure service::telemetry::metrics::views instead.")) From 283093ce3e7ac9df852c16effc6f732ab3752558 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 5 Aug 2025 08:10:10 +0800 Subject: [PATCH 5/7] More helpful subtext --- .chloggen/service-deprecate-featuregate.yaml | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.chloggen/service-deprecate-featuregate.yaml b/.chloggen/service-deprecate-featuregate.yaml index 8618b9e790eb..a361258c845d 100644 --- a/.chloggen/service-deprecate-featuregate.yaml +++ b/.chloggen/service-deprecate-featuregate.yaml @@ -17,7 +17,34 @@ issues: [13537] # Use pipe (|) for multiline entries. subtext: | The feature gate is now deprecated since metric views can be configured. - The gate will be removed in v0.134.0. + The feature gate will be removed in v0.134.0. + + The metrics attributes removed by this feature gate are no longer emitted + by the Collector by default, but if needed, you can achieve the same + functionality by configuring the following metric views: + + ```yaml + service: + telemetry: + metrics: + level: detailed + views: + - selector: + meter_name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" + stream: + attribute_keys: + excluded: ["net.sock.peer.addr", "net.sock.peer.port", "net.sock.peer.name"] + - selector: + meter_name: "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" + stream: + attribute_keys: + excluded: ["net.host.name", "net.host.port"] + ``` + + Note that this requires setting `service::telemetry::metrics::level: detailed`. + If you have a strong use case for using views in combination with a different + level, please show your interest in + https://github.com/open-telemetry/opentelemetry-collector/issues/10769. # Optional: The change log or logs in which this entry should be included. # e.g. '[user]' or '[user, api]' From de1f11a76587f2a0ba5018c70257b6349514a81c Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 5 Aug 2025 08:13:45 +0800 Subject: [PATCH 6/7] Update cspell dictionary --- .github/workflows/utils/cspell.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/utils/cspell.json b/.github/workflows/utils/cspell.json index e75fa058d30b..b078dccb5c17 100644 --- a/.github/workflows/utils/cspell.json +++ b/.github/workflows/utils/cspell.json @@ -335,6 +335,8 @@ "otelcol", "otelcoltest", "otelcorecol", + "otelgrpc", + "otelhttp", "otelsvc", "oteltest", "otelzap", From e7223b324938b1aaf697d2921410edfc95a38b16 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 5 Aug 2025 14:35:44 +0200 Subject: [PATCH 7/7] Update .chloggen/service-deprecate-featuregate.yaml Co-authored-by: Jade Guiton --- .chloggen/service-deprecate-featuregate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/service-deprecate-featuregate.yaml b/.chloggen/service-deprecate-featuregate.yaml index a361258c845d..f4af4db826b7 100644 --- a/.chloggen/service-deprecate-featuregate.yaml +++ b/.chloggen/service-deprecate-featuregate.yaml @@ -19,7 +19,7 @@ subtext: | The feature gate is now deprecated since metric views can be configured. The feature gate will be removed in v0.134.0. - The metrics attributes removed by this feature gate are no longer emitted + The metric attributes removed by this feature gate are no longer emitted by the Collector by default, but if needed, you can achieve the same functionality by configuring the following metric views: