Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
54 changes: 54 additions & 0 deletions .chloggen/service-deprecate-featuregate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 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]'
# 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]
2 changes: 2 additions & 0 deletions .github/workflows/utils/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@
"otelcol",
"otelcoltest",
"otelcorecol",
"otelgrpc",
"otelhttp",
"otelsvc",
"oteltest",
"otelzap",
Expand Down
55 changes: 8 additions & 47 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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"
nooptrace "go.opentelemetry.io/otel/trace/noop"
"go.uber.org/multierr"
"go.uber.org/zap"
Expand All @@ -43,13 +42,14 @@ 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.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("0.133.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
Expand Down Expand Up @@ -130,11 +130,7 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) {
pcommonRes := pdataFromSdk(res)

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)
}

Expand Down Expand Up @@ -386,41 +382,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 {
Expand Down
16 changes: 5 additions & 11 deletions service/telemetry/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.26.0"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
Expand Down Expand Up @@ -59,9 +59,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,
Expand All @@ -70,8 +68,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,
Expand Down Expand Up @@ -157,16 +154,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"),
)))
}

Expand Down
Loading