Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2

### :bug: Bug Fixes

* fix(sdk-trace): include trace IDs at the ratio 1 upper bound in `TraceIdRatioBasedSampler` [#6890](https://github.com/open-telemetry/opentelemetry-js/pull/6890) @LarryHu0217

### :books: Documentation

### :house: Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export class TraceIdRatioBasedSampler implements Sampler {

constructor(ratio = 0) {
this._ratio = this._normalize(ratio);
this._upperBound = Math.floor(this._ratio * 0xffffffff);
this._upperBound =
this._ratio === 1 ? 0x100000000 : Math.floor(this._ratio * 0xffffffff);
}

shouldSample(context: unknown, traceId: string): SamplingResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ describe('TraceIdRatioBasedSampler', () => {
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
}
);

assert.deepStrictEqual(
sampler.shouldSample(
spanContext(traceId('ffffffff')),
traceId('ffffffff')
),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
}
);
});

it('should return a always sampler for >1', () => {
Expand Down
Loading