Skip to content

Commit

Permalink
Revert "fix(opentelemetry-core): traceState in sampler tests"
Browse files Browse the repository at this point in the history
This reverts commit c4f174b.
  • Loading branch information
raphael-theriault-swi committed Feb 2, 2023
1 parent b51fdea commit a27dbac
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ describe('AlwaysOffSampler', () => {

it('should return decision: api.SamplingDecision.NOT_RECORD for AlwaysOffSampler', () => {
const sampler = new AlwaysOffSampler();
assert.deepStrictEqual(sampler.shouldSample(api.ROOT_CONTEXT), {
assert.deepStrictEqual(sampler.shouldSample(), {
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ describe('AlwaysOnSampler', () => {

it('should return api.SamplingDecision.RECORD_AND_SAMPLED for AlwaysOnSampler', () => {
const sampler = new AlwaysOnSampler();
assert.deepStrictEqual(sampler.shouldSample(api.ROOT_CONTEXT), {
assert.deepStrictEqual(sampler.shouldSample(), {
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ describe('ParentBasedSampler', () => {
),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -86,7 +85,6 @@ describe('ParentBasedSampler', () => {
),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
}
);
});
Expand All @@ -105,7 +103,6 @@ describe('ParentBasedSampler', () => {
),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
}
);
});
Expand All @@ -129,7 +126,6 @@ describe('ParentBasedSampler', () => {
),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
}
);
});
Expand All @@ -148,7 +144,6 @@ describe('ParentBasedSampler', () => {
),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -167,7 +162,6 @@ describe('ParentBasedSampler', () => {
),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import * as assert from 'assert';
import * as api from '@opentelemetry/api';
import { TraceIdRatioBasedSampler } from '../../src/trace/sampler/TraceIdRatioBasedSampler';

const spanContext = (traceId = '1') =>
api.trace.setSpanContext(api.ROOT_CONTEXT, {
traceId,
spanId: '1.1',
traceFlags: api.TraceFlags.NONE,
});
const spanContext = (traceId = '1') => ({
traceId,
spanId: '1.1',
traceFlags: api.TraceFlags.NONE,
});

const traceId = (part: string) => ('0'.repeat(32) + part).slice(-32);

Expand Down Expand Up @@ -60,7 +59,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
}
);
});
Expand All @@ -71,7 +69,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
}
);
});
Expand All @@ -82,7 +79,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -93,7 +89,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -105,7 +100,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -117,7 +111,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -129,7 +122,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -140,7 +132,6 @@ describe('TraceIdRatioBasedSampler', () => {
sampler.shouldSample(spanContext(traceId('1')), traceId('1')),
{
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
}
);

Expand All @@ -151,7 +142,6 @@ describe('TraceIdRatioBasedSampler', () => {
),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -160,14 +150,12 @@ describe('TraceIdRatioBasedSampler', () => {
const sampler = new TraceIdRatioBasedSampler(1);
assert.deepStrictEqual(sampler.shouldSample(spanContext(''), ''), {
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
});

assert.deepStrictEqual(
sampler.shouldSample(spanContext(traceId('g')), traceId('g')),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand All @@ -179,36 +167,30 @@ describe('TraceIdRatioBasedSampler', () => {
const id1 = traceId((Math.floor(0xffffffff * 0.1) - 1).toString(16));
assert.deepStrictEqual(sampler10.shouldSample(spanContext(id1), id1), {
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
});
assert.deepStrictEqual(sampler20.shouldSample(spanContext(id1), id1), {
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
});

const id2 = traceId((Math.floor(0xffffffff * 0.2) - 1).toString(16));
assert.deepStrictEqual(sampler10.shouldSample(spanContext(id2), id2), {
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
});
assert.deepStrictEqual(sampler20.shouldSample(spanContext(id2), id2), {
decision: api.SamplingDecision.RECORD_AND_SAMPLED,
traceState: undefined,
});

const id2delta = traceId(Math.floor(0xffffffff * 0.2).toString(16));
assert.deepStrictEqual(
sampler10.shouldSample(spanContext(id2delta), id2delta),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
assert.deepStrictEqual(
sampler20.shouldSample(spanContext(id2delta), id2delta),
{
decision: api.SamplingDecision.NOT_RECORD,
traceState: undefined,
}
);
});
Expand Down

0 comments on commit a27dbac

Please sign in to comment.