Skip to content

Commit 661a11b

Browse files
committed
address pr comments
1 parent c8e32bb commit 661a11b

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ describe('continueTrace', () => {
20232023
});
20242024
});
20252025

2026-
it('works inside an active span', () => {
2026+
it('updates the propagation context when called inside an active span', () => {
20272027
const client = new TestClient(
20282028
getDefaultTestClientOptions({
20292029
dsn: 'https://username@domain/123',
@@ -2055,6 +2055,41 @@ describe('continueTrace', () => {
20552055
);
20562056
});
20572057
});
2058+
2059+
it('sets the correct trace and parent span ids when called inside an active span and a new span is started from within the callback', () => {
2060+
const client = new TestClient(
2061+
getDefaultTestClientOptions({
2062+
dsn: 'https://username@domain/123',
2063+
tracesSampleRate: 1,
2064+
}),
2065+
);
2066+
setCurrentClient(client);
2067+
client.init();
2068+
2069+
const sentryTrace = '12312012123120121231201212312012-1121201211212012-1';
2070+
const sentryTraceId = '12312012123120121231201212312012';
2071+
const sentrySpanId = '1121201211212012';
2072+
const sentryBaggage = 'sentry-org_id=123';
2073+
2074+
startSpan({ name: 'outer' }, () => {
2075+
continueTrace(
2076+
{
2077+
sentryTrace: sentryTrace,
2078+
baggage: sentryBaggage,
2079+
},
2080+
() => {
2081+
startSpan({ name: 'inner' }, (span) => {
2082+
const innerSpanJson = spanToJSON(span);
2083+
const innerTraceId = innerSpanJson.trace_id;
2084+
const innerParentSpanId = innerSpanJson.parent_span_id;
2085+
2086+
expect(innerTraceId).toBe(sentryTraceId);
2087+
expect(innerParentSpanId).toBe(sentrySpanId);
2088+
});
2089+
},
2090+
);
2091+
});
2092+
});
20582093
});
20592094

20602095
describe('getActiveSpan', () => {

0 commit comments

Comments
 (0)