1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-25 22:41:46 +02:00

Enable exemplars by default (#5778)

Part of https://github.com/open-telemetry/opentelemetry-go/issues/5249.

Addresses
https://github.com/open-telemetry/opentelemetry-go/issues/5249#issuecomment-2088725450

This removes handling of the `OTEL_GO_X_EXEMPLAR` environment variable.

Instead of changing the default for the existing environment variable to
enable it by default, i'm just removing it entirely. Users can still
disable the feature by setting the filter to always_off. Since we will
continue to support that configuration, it seems better to direct users
there, rather than give them a temporary equivalent.
This commit is contained in:
David Ashpole
2024-09-11 15:07:14 -04:00
committed by GitHub
parent 97ee172f1f
commit 6e2f72f698
6 changed files with 53 additions and 94 deletions

View File

@@ -448,59 +448,46 @@ func TestExemplars(t *testing.T) {
})
sampled := trace.ContextWithSpanContext(context.Background(), sc)
t.Run("OTEL_GO_X_EXEMPLAR=true", func(t *testing.T) {
t.Setenv("OTEL_GO_X_EXEMPLAR", "true")
t.Run("Default", func(t *testing.T) {
m, r := setup("default")
measure(ctx, m)
check(t, r, 0, 0, 0)
t.Run("Default", func(t *testing.T) {
m, r := setup("default")
measure(ctx, m)
check(t, r, 0, 0, 0)
measure(sampled, m)
check(t, r, nCPU, 1, 20)
})
t.Run("Invalid", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "unrecognized")
m, r := setup("default")
measure(ctx, m)
check(t, r, 0, 0, 0)
measure(sampled, m)
check(t, r, nCPU, 1, 20)
})
t.Run("always_on", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "always_on")
m, r := setup("always_on")
measure(ctx, m)
check(t, r, nCPU, 1, 20)
})
t.Run("always_off", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "always_off")
m, r := setup("always_off")
measure(ctx, m)
check(t, r, 0, 0, 0)
})
t.Run("trace_based", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "trace_based")
m, r := setup("trace_based")
measure(ctx, m)
check(t, r, 0, 0, 0)
measure(sampled, m)
check(t, r, nCPU, 1, 20)
})
measure(sampled, m)
check(t, r, nCPU, 1, 20)
})
t.Run("OTEL_GO_X_EXEMPLAR=false", func(t *testing.T) {
t.Setenv("OTEL_GO_X_EXEMPLAR", "false")
t.Run("Invalid", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "unrecognized")
m, r := setup("default")
measure(ctx, m)
check(t, r, 0, 0, 0)
measure(sampled, m)
check(t, r, nCPU, 1, 20)
})
t.Run("always_on", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "always_on")
m, r := setup("always_on")
measure(ctx, m)
check(t, r, nCPU, 1, 20)
})
t.Run("always_off", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "always_off")
m, r := setup("always_off")
measure(ctx, m)
check(t, r, 0, 0, 0)
})
t.Run("trace_based", func(t *testing.T) {
t.Setenv("OTEL_METRICS_EXEMPLAR_FILTER", "trace_based")
m, r := setup("trace_based")
measure(ctx, m)
check(t, r, 0, 0, 0)
measure(sampled, m)
check(t, r, nCPU, 1, 20)
})
}