Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 67379f8

Browse files
authored
fix: make no option flags behave the same as o=1 (#910)
1 parent 015f088 commit 67379f8

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/trace-api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ export class StackdriverTracer implements Tracer {
180180
parsedContext = util.parseContextFromHeader(options.traceContext);
181181
}
182182
if (parsedContext) {
183+
if (parsedContext.options === undefined) {
184+
// If there are no incoming option flags, default to 0x1.
185+
parsedContext.options = 1;
186+
}
183187
Object.assign(incomingTraceContext, parsedContext);
184188
} else if (
185189
this.config!.contextHeaderBehavior ===

test/test-trace-api.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,17 @@ describe('Trace Interface', () => {
275275
testTraceModule.getSpans(span => span.name === 'root3').length, 0);
276276
});
277277

278+
it('should trace if no option flags are provided', () => {
279+
createTraceAgent({enhancedDatabaseReporting: false})
280+
.runInRootSpan(
281+
{name: 'root', traceContext: '123456/667'}, (rootSpan) => {
282+
rootSpan.endSpan();
283+
});
284+
const foundTrace =
285+
testTraceModule.getOneTrace(trace => trace.traceId === '123456');
286+
assert.strictEqual(foundTrace.spans.length, 1);
287+
});
288+
278289
describe('getting response trace context', () => {
279290
it('should behave as expected', () => {
280291
const fakeTraceId = 'ffeeddccbbaa99887766554433221100';

0 commit comments

Comments
 (0)