Skip to content

Commit

Permalink
fix(sdk-trace-base)!: use parent-base-always-on on incorrect input (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Feb 25, 2025
1 parent d9eae58 commit 455a352
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* (user-facing): all configuration previously possible via `window.OTEL_*` is now not supported anymore
* If you have been using the `envDetector` in browser environments, please migrate to manually creating a resource.
* Note: Node.js environment variable configuration continues to work as-is.
* fix(sdk-trace-base)!: use `ParentBasedAlwaysOnSampler` over `AlwaysOnSampler` when bogus data is supplied to `OTEL_TRACES_SAMPLER`
* this aligns the SDK implementation with the specification
* feat(core)!: drop `getEnv()`, `getEnvWithoutDefaults()` [#5481](/~https://github.com/open-telemetry/opentelemetry-js/pull/5481) @pichlermarc
* (user-facing): `getEnv()` has been replaced by `getStringFromEnv()`, `getNumberFromEnv()`, `getBooleanFromEnv()`, `getStringListFromEnv()`
* these new functions do not include defaults, please inline any defaults if necessary (example: `getStringFromEnv("OTEL_FOO") ?? "my-default"`)
Expand Down
7 changes: 4 additions & 3 deletions packages/opentelemetry-sdk-trace-base/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const enum TracesSamplerValues {
TraceIdRatio = 'traceidratio',
}

const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn;
const DEFAULT_RATIO = 1;

/**
Expand Down Expand Up @@ -96,9 +95,11 @@ export function buildSamplerFromEnv(): Sampler {
});
default:
diag.error(
`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${FALLBACK_OTEL_TRACES_SAMPLER}".`
`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${TracesSamplerValues.ParentBasedAlwaysOn}".`
);
return new AlwaysOnSampler();
return new ParentBasedSampler({
root: new AlwaysOnSampler(),
});
}
}

Expand Down

0 comments on commit 455a352

Please sign in to comment.