Skip to content

Commit

Permalink
fix baggage items at the span level instead of trace level (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev authored Dec 19, 2018
1 parent c777e5b commit c7260e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/opentracing/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DatadogSpan extends Span {
parentId: parent._spanId,
sampled: parent._sampled,
sampling: parent._sampling,
baggageItems: Object.assign({}, parent._baggageItems),
baggageItems: parent._baggageItems,
trace: parent._trace.started.length !== parent._trace.finished.length ? parent._trace : null
})
} else {
Expand Down
16 changes: 14 additions & 2 deletions test/opentracing/span.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,23 @@ describe('Span', () => {
})

describe('setBaggageItem', () => {
it('should set a baggage item', () => {
span = new Span(tracer, recorder, sampler, prioritySampler, { operationName: 'operation' })
it('should set a baggage item on the trace', () => {
const parent = {
traceId: new Uint64BE(123, 123),
spanId: new Uint64BE(456, 456),
_sampled: false,
_baggageItems: {},
_trace: {
started: ['span'],
finished: ['span']
}
}

span = new Span(tracer, recorder, sampler, prioritySampler, { operationName: 'operation', parent })
span.setBaggageItem('foo', 'bar')

expect(span.context()._baggageItems).to.have.property('foo', 'bar')
expect(parent._baggageItems).to.have.property('foo', 'bar')
})
})

Expand Down

0 comments on commit c7260e1

Please sign in to comment.