commit 2effc76f12019edc9689388204ab9faab63ff8f4 Author: Bryan Aguilar Date: Tue Jul 25 17:33:22 2023 -0700 Add feature gate for instrumentation scope in statsd receiver diff --git a/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go b/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go index 1cfec5cf..699d6ee7 100644 --- a/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go +++ b/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go @@ -14,6 +14,7 @@ import ( "github.com/lightstep/go-expohisto/structure" "go.opentelemetry.io/collector/client" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/featuregate" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/otel/attribute" @@ -30,6 +31,13 @@ type ( ObserverType string // How the server will aggregate histogram and timings ("gauge", "summary") ) +var instNameFeatGate = featuregate.GlobalRegistry().MustRegister("aws.statsd.populateInstrumentationScope", + featuregate.StageAlpha, + featuregate.WithRegisterFromVersion("v0.82.0"), + featuregate.WithRegisterDescription("populates instrumentation scope library name on StatsD receiver "+ + "metric data points"), +) + const ( tagMetricType = "metric_type" @@ -194,21 +202,35 @@ func (p *StatsDParser) GetMetrics() []BatchMetrics { } rm := batch.Metrics.ResourceMetrics().AppendEmpty() for _, metric := range instrument.gauges { - p.copyMetricAndScope(rm, metric) + if instNameFeatGate.IsEnabled() { + p.copyMetricAndScope(rm, metric) + } else { + metric.CopyTo(rm.ScopeMetrics().AppendEmpty()) + } } for _, metric := range instrument.timersAndDistributions { - p.copyMetricAndScope(rm, metric) + if instNameFeatGate.IsEnabled() { + p.copyMetricAndScope(rm, metric) + } else { + metric.CopyTo(rm.ScopeMetrics().AppendEmpty()) + } } for _, metric := range instrument.counters { setTimestampsForCounterMetric(metric, p.lastIntervalTime, now) - p.copyMetricAndScope(rm, metric) + if instNameFeatGate.IsEnabled() { + p.copyMetricAndScope(rm, metric) + } else { + metric.CopyTo(rm.ScopeMetrics().AppendEmpty()) + } } for desc, summaryMetric := range instrument.summaries { ilm := rm.ScopeMetrics().AppendEmpty() - p.setVersionAndNameScope(ilm.Scope()) + if instNameFeatGate.IsEnabled() { + p.setVersionAndNameScope(ilm.Scope()) + } buildSummaryMetric( desc, @@ -222,8 +244,10 @@ func (p *StatsDParser) GetMetrics() []BatchMetrics { for desc, histogramMetric := range instrument.histograms { ilm := rm.ScopeMetrics().AppendEmpty() - p.setVersionAndNameScope(ilm.Scope()) + if instNameFeatGate.IsEnabled() { + p.setVersionAndNameScope(ilm.Scope()) + } buildHistogramMetric( desc, histogramMetric,