it('must treat sampling priority changes specially', () => { const span = new Span(tracerInstance, 'rpc'); span.setTag(opentracing.Tags.SAMPLING_PRIORITY, 0.5); expect(span.context().samplingPriority).to.equal(0.5); });
describe('finish', () => { it('must pass span to spanBuffer handler when finishing', () => { const span = new Span(tracerInstance, 'rpc'); span.finish(); expect(spanBuffer.addSpan.callCount).to.equal(1); expect(spanBuffer.addSpan.getCall(0).args[0]).to.equal(span.span); }); it('must pass span to spanBuffer handler when finishing with user defined end time', () => { const span = new Span(tracerInstance, 'rpc'); span.finish(span.span.ts + 6); expect(spanBuffer.addSpan.callCount).to.equal(1); expect(spanBuffer.addSpan.getCall(0).args[0]).to.equal(span.span); expect(span.span.d).to.equal(6); }); it('must not transmit span when sampling priority is 0', () => { const span = new Span(tracerInstance, 'rpc'); span.setTag(opentracing.Tags.SAMPLING_PRIORITY, 0); span.finish(); expect(spanBuffer.addSpan.callCount).to.equal(0); }); });
it('must copy sampling priority from parent span', () => { const span = new Span(tracerInstance, 'rpc'); span.setTag(opentracing.Tags.SAMPLING_PRIORITY, 0); const child = new Span(tracerInstance, 'oauth', { references: [opentracing.childOf(span)] }); child.finish(); expect(spanBuffer.addSpan.callCount).to.equal(0); });
span.setTag(opentracing.Tags.SAMPLING_PRIORITY, 0.5); tracer.inject(span, opentracing.FORMAT_TEXT_MAP, carrier); expect(carrier).to.deep.equal({