Skip to content

Commit 2447a81

Browse files
authored
[component] Deprecate TelemetrySettings.MetricsLevel (#12159)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number if applicable --> - Deprecates `component.TelemetrySettings.MetricsLevel` - Sets the value passed to components to always be `configtelemetry.LevelDetailed` #### Link to tracking issue Updates #11061
1 parent e8807bf commit 2447a81

File tree

7 files changed

+34
-6
lines changed

7 files changed

+34
-6
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: deprecation
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: component
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecate `component.TelemetrySettings.MetricsLevel` in favor of using views and 'Enabled' method.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12159]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
- Components will temporarily need the service to support using views.
20+
21+
# Optional: The change log or logs in which this entry should be included.
22+
# e.g. '[user]' or '[user, api]'
23+
# Include 'user' if the change is relevant to end users.
24+
# Include 'api' if there is a change to a library API.
25+
# Default: '[user]'
26+
change_logs: [api]

component/componenttest/nop_telemetry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ func TestNewNopTelemetrySettings(t *testing.T) {
2222
assert.NotPanics(t, func() {
2323
nts.MeterProvider.Meter("test")
2424
})
25-
assert.Equal(t, configtelemetry.LevelNone, nts.MetricsLevel)
25+
assert.Equal(t, configtelemetry.LevelNone, nts.MetricsLevel) //nolint:staticcheck
2626
assert.Equal(t, 0, nts.Resource.Attributes().Len())
2727
}

component/componenttest/telemetry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func NewTelemetry(opts ...TelemetryOption) Telemetry {
6868
func (tt *Telemetry) NewTelemetrySettings() component.TelemetrySettings {
6969
set := NewNopTelemetrySettings()
7070
set.MeterProvider = tt.meterProvider
71-
set.MetricsLevel = configtelemetry.LevelDetailed
71+
set.MetricsLevel = configtelemetry.LevelDetailed //nolint:staticcheck //SA1019
7272
set.TracerProvider = tt.traceProvider
7373
return set
7474
}

component/componenttest/telemetry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestNewTelemetry(t *testing.T) {
2020
assert.NotNil(t, tel.Reader)
2121
assert.NotNil(t, tel.SpanRecorder)
2222
set := tel.NewTelemetrySettings()
23-
assert.Equal(t, configtelemetry.LevelDetailed, set.MetricsLevel)
23+
assert.Equal(t, configtelemetry.LevelDetailed, set.MetricsLevel) //nolint:staticcheck //SA1019
2424
assert.IsType(t, &sdktrace.TracerProvider{}, set.TracerProvider)
2525
assert.IsType(t, &sdkmetric.MeterProvider{}, set.MeterProvider)
2626
require.NoError(t, tel.Shutdown(context.Background()))

component/telemetry.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type TelemetrySettings struct {
2727
// MetricsLevel represents the configuration value set when the collector
2828
// is configured. Components may use this level to decide whether it is
2929
// appropriate to avoid computationally expensive calculations.
30+
//
31+
// Deprecated: [v0.119.0] Use https://pkg.go.dev/go.opentelemetry.io/otel/sdk/[email protected]/internal/x#readme-instrument-enabled instead.
32+
// Components will temporarily need to add a view to `service/telemetry` to drop metrics based on the level.
3033
MetricsLevel configtelemetry.Level
3134

3235
// Resource contains the resource attributes for the collector's telemetry.

config/confighttp/confighttp_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"go.opentelemetry.io/collector/config/configauth"
3030
"go.opentelemetry.io/collector/config/configcompression"
3131
"go.opentelemetry.io/collector/config/configopaque"
32-
"go.opentelemetry.io/collector/config/configtelemetry"
3332
"go.opentelemetry.io/collector/config/configtls"
3433
"go.opentelemetry.io/collector/extension/auth"
3534
"go.opentelemetry.io/collector/extension/auth/authtest"
@@ -49,7 +48,7 @@ var (
4948
dummyID = component.MustNewID("dummy")
5049
nonExistingID = component.MustNewID("nonexisting")
5150
// Omit TracerProvider and MeterProvider in TelemetrySettings as otelhttp.Transport cannot be introspected
52-
nilProvidersSettings = component.TelemetrySettings{Logger: zap.NewNop(), MetricsLevel: configtelemetry.LevelNone}
51+
nilProvidersSettings = component.TelemetrySettings{Logger: zap.NewNop()}
5352
)
5453

5554
func TestAllHTTPClientSettings(t *testing.T) {

config/confighttp/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require (
1414
go.opentelemetry.io/collector/config/configauth v0.118.0
1515
go.opentelemetry.io/collector/config/configcompression v1.24.0
1616
go.opentelemetry.io/collector/config/configopaque v1.24.0
17-
go.opentelemetry.io/collector/config/configtelemetry v0.118.0
1817
go.opentelemetry.io/collector/config/configtls v1.24.0
1918
go.opentelemetry.io/collector/extension/auth v0.118.0
2019
go.opentelemetry.io/collector/extension/auth/authtest v0.118.0
@@ -35,6 +34,7 @@ require (
3534
github.com/google/uuid v1.6.0 // indirect
3635
github.com/pmezard/go-difflib v1.0.0 // indirect
3736
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
37+
go.opentelemetry.io/collector/config/configtelemetry v0.118.0 // indirect
3838
go.opentelemetry.io/collector/extension v0.118.0 // indirect
3939
go.opentelemetry.io/collector/pdata v1.24.0 // indirect
4040
go.opentelemetry.io/otel/metric v1.34.0 // indirect

0 commit comments

Comments
 (0)