Skip to content

Commit 455a352

Browse files
authored
fix(sdk-trace-base)!: use parent-base-always-on on incorrect input (#5494)
1 parent d9eae58 commit 455a352

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
112112
* (user-facing): all configuration previously possible via `window.OTEL_*` is now not supported anymore
113113
* If you have been using the `envDetector` in browser environments, please migrate to manually creating a resource.
114114
* Note: Node.js environment variable configuration continues to work as-is.
115+
* fix(sdk-trace-base)!: use `ParentBasedAlwaysOnSampler` over `AlwaysOnSampler` when bogus data is supplied to `OTEL_TRACES_SAMPLER`
116+
* this aligns the SDK implementation with the specification
115117
* feat(core)!: drop `getEnv()`, `getEnvWithoutDefaults()` [#5481](https://github.com/open-telemetry/opentelemetry-js/pull/5481) @pichlermarc
116118
* (user-facing): `getEnv()` has been replaced by `getStringFromEnv()`, `getNumberFromEnv()`, `getBooleanFromEnv()`, `getStringListFromEnv()`
117119
* these new functions do not include defaults, please inline any defaults if necessary (example: `getStringFromEnv("OTEL_FOO") ?? "my-default"`)

packages/opentelemetry-sdk-trace-base/src/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const enum TracesSamplerValues {
3131
TraceIdRatio = 'traceidratio',
3232
}
3333

34-
const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn;
3534
const DEFAULT_RATIO = 1;
3635

3736
/**
@@ -96,9 +95,11 @@ export function buildSamplerFromEnv(): Sampler {
9695
});
9796
default:
9897
diag.error(
99-
`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${FALLBACK_OTEL_TRACES_SAMPLER}".`
98+
`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${TracesSamplerValues.ParentBasedAlwaysOn}".`
10099
);
101-
return new AlwaysOnSampler();
100+
return new ParentBasedSampler({
101+
root: new AlwaysOnSampler(),
102+
});
102103
}
103104
}
104105

0 commit comments

Comments
 (0)