Skip to content

Commit 8ddb3df

Browse files
Ashish AggarwalAshish Aggarwal
authored andcommitted
set parent spanid default as empty
1 parent 4165f7b commit 8ddb3df

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/tracer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default class Tracer extends opentracing.Tracer {
121121
private _createSpanContext(parent: SpanContext, spanTags: { [key: string]: any }): SpanContext {
122122
if (!parent || !parent.isValid) {
123123
const parentBaggage = parent && parent.baggage;
124-
return new SpanContext(this._idGenerator.generate(), this._idGenerator.generate(), parentBaggage);
124+
return new SpanContext(this._idGenerator.generate(), this._idGenerator.generate(), '', parentBaggage);
125125
} else {
126126
if (!this._useDualSpanMode && (this.isServerSpan(spanTags) || parent.isExtractedContext())) {
127127
return new SpanContext(parent.traceId, parent.spanId, parent.parentSpanId, parent.baggage);

tests/unit/tracer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('Tracer tests', () => {
6464
expectSpansInStore(inMemSpanStore, 1);
6565
const receivedSpan = inMemSpanStore.spans()[0];
6666
expect(receivedSpan.operationName()).eq(dummyOperation);
67-
expect(isUndefined(receivedSpan.context().parentSpanId)).eq(true);
67+
expect(receivedSpan.context().parentSpanId).eq('');
6868
});
6969

7070
it('should start and dispatch server and client spans', () => {
@@ -97,7 +97,7 @@ describe('Tracer tests', () => {
9797
expect(receivedServerSpan.operationName()).eq(dummyOperation);
9898
expect(receivedClientSpan.duration() <= receivedServerSpan.duration()).eq(true);
9999
expect(receivedClientSpan.context().parentSpanId).eq(receivedServerSpan.context().spanId);
100-
expect(isUndefined(receivedServerSpan.context().parentSpanId)).eq(true);
100+
expect(receivedServerSpan.context().parentSpanId).eq('');
101101
expect(receivedServerSpan.context().traceId).eq(receivedClientSpan.context().traceId);
102102

103103
expect(receivedClientSpan.logs().length).eq(1);

0 commit comments

Comments
 (0)