Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Revert "Add support for deferred sampling (#107)" (#113)
Browse files Browse the repository at this point in the history
This reverts commit caac859.
  • Loading branch information
black-adder committed Apr 24, 2017
1 parent 950f336 commit 7bb07a3
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 64 deletions.
5 changes: 0 additions & 5 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export const SAMPLED_MASK = 0x1;
// DEBUG_MASK is the bit mask indicationg that a span has been marked for debug.
export const DEBUG_MASK = 0x2;

// DEFERRED_SAMPLING_MASK is the bit mask indicating that the upstream service that generated the
// span did not make a definitive sampling decision, but deferred it to be made by some
// downstream service.
export const DEFERRED_SAMPLING_MASK = 0x4;

// JAEGER_CLIENT_VERSION_TAG_KEY is the name of the tag used to report client version.
export const JAEGER_CLIENT_VERSION_TAG_KEY = 'jaeger.version';

Expand Down
8 changes: 0 additions & 8 deletions src/span_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,6 @@ export default class SpanContext {
return !!((this._traceId || this._traceIdStr) && (this._spanId || this._spanIdStr));
}

get isDeferredSampling(): boolean {
return (this._flags & constants.DEFERRED_SAMPLING_MASK) === constants.DEFERRED_SAMPLING_MASK;
}

unsetDeferredSampling(): void {
this._flags &= ~constants.DEFERRED_SAMPLING_MASK;
}

finalizeSampling(): void {
this._samplingFinalized = true;
}
Expand Down
22 changes: 0 additions & 22 deletions src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export default class Tracer {
ctx.baggage = parent.baggage;

parent.finalizeSampling();
this.processDeferredSampling(ctx, operationName, internalTags);
ctx.finalizeSampling();
}

Expand All @@ -253,27 +252,6 @@ export default class Tracer {
);
}

/**
* Makes a concrete sampling decision for the ctx span context based on information
* available to it's child span.
*
* The ctx context's deferred mask is unset after this decision is made
*
* @param ctx the span context
* @param operationName the operation name for the child
* @param tags tags to be applied by the sampler
*/
processDeferredSampling(ctx: SpanContext, operationName: string, tags: any) {
if (ctx.isDeferredSampling) {
if (this._sampler.isSampled(operationName, tags)) {
ctx._flags |= constants.SAMPLED_MASK;
} else {
ctx._flags &= ~constants.SAMPLED_MASK;
}
ctx.unsetDeferredSampling();
}
}

/**
* Saves the span context into the carrier object for various formats, and encoders.
*
Expand Down
30 changes: 1 addition & 29 deletions test/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,34 +185,6 @@ describe('span should', () => {
assert.isOk(unnormalizedKey in Span._getBaggageHeaderCache());
});

describe('with deferred sampling', () => {
beforeEach(function () {
spanContext._flags = constants.DEFERRED_SAMPLING_MASK;
});
it('should not pass deferred sampling flag to child spans', () => {
let child = tracer.startSpan('child', {childOf: span.context()});
assert.notEqual(child.context.flags & constants.DEFERRED_SAMPLING_MASK,
constants.DEFERRED_SAMPLING_MASK);
assert.isOk(child._spanContext.samplingFinalized);
});

it('should make a call to the underlying sampler and use the sampling decision when true', () => {
let mockSampler = sinon.mock(tracer._sampler);
mockSampler.expects('isSampled').withExactArgs('goodOperation', {}).returns(true);
let child = tracer.startSpan('goodOperation', {childOf: span.context()});
mockSampler.verify();
assert.isOk(child.context().isSampled());
});

it('should make a call to the underlying sampler and use the sampling decision when false', () => {
let mockSampler = sinon.mock(tracer._sampler);
mockSampler.expects('isSampled').withExactArgs('horridOperation', {}).returns(false);
let child = tracer.startSpan('horridOperation', {childOf: span.context()});
mockSampler.verify();
assert.isNotOk(child.context().isSampled());
});
});

describe('adaptive sampling tests for span', () => {
let options = [
{ desc: 'sampled: ', sampling: true, reportedSpans: 1 },
Expand Down Expand Up @@ -341,7 +313,7 @@ describe('span should', () => {
tracer._sampler = new ProbabilisticSampler(1.0);

// The second cal lshould rename the operation name, but
// not re-sample the span. This is because finalize was set
// not re-sample the span. This is because finalize was set
// in the first 'setOperationName' call.
span.setOperationName('new-span-two');

Expand Down

0 comments on commit 7bb07a3

Please sign in to comment.