it('must copy baggage from parent span', () => { const span = new Span(tracerInstance, 'rpc'); span.setBaggageItem('foo', 'bar'); const child = new Span(tracerInstance, 'oauth', { references: [opentracing.childOf(span)] }); expect(span.getBaggageItem('foo')).to.equal('bar'); expect(child.getBaggageItem('foo')).to.equal('bar'); });
it('must support child of span contexts with missing trace relation data', () => { const span = new Span(tracerInstance, 'rpc'); const parentContext = span.context(); delete parentContext.t; delete parentContext.s; const child = new Span(tracerInstance, 'oauth', { references: [opentracing.childOf(parentContext)] }); expect(child.span.t).to.equal(child.span.s); });
it('must set trace and parent ID based on child of reference', () => { const span = new Span(tracerInstance, 'rpc'); const child = new Span(tracerInstance, 'oauth', { references: [opentracing.childOf(span)] }); expect(child.span.t).to.equal(span.span.t); expect(child.span.p).to.equal(span.span.s); expect(child.span.s).not.to.equal(span.span.s); });
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); });
it('must actually copy baggage to keep future baggage mutations from propagating', () => { const span = new Span(tracerInstance, 'rpc'); span.setBaggageItem('foo', 'bar'); const child = new Span(tracerInstance, 'oauth', { references: [opentracing.childOf(span)] }); child.setBaggageItem('foo', 'blub'); expect(span.getBaggageItem('foo')).to.equal('bar'); expect(child.getBaggageItem('foo')).to.equal('blub'); });