Skip to content

Commit d5af638

Browse files
mydeaLuca Forstner
andauthored
feat!: Remove spanId from propagation context (#14733)
Closes #12385 This also deprecates `getPropagationContextFromSpan` as it is no longer used/needed. We may think about removing this in v9, but IMHO we can also just leave this for v9, it does not hurt too much to have it in there... --------- Co-authored-by: Luca Forstner <luca.forstner@sentry.io>
1 parent d4e94fe commit d5af638

File tree

38 files changed

+190
-401
lines changed

38 files changed

+190
-401
lines changed

dev-packages/browser-integration-tests/suites/public-api/startSpan/parallel-root-spans-with-parentSpanId/subject.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
Sentry.getCurrentScope().setPropagationContext({
22
parentSpanId: '1234567890123456',
3-
spanId: '123456789012345x',
43
traceId: '12345678901234567890123456789012',
54
});
65

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
integrations: integrations => {
8+
integrations.push(Sentry.browserTracingIntegration());
9+
return integrations.filter(i => i.name !== 'BrowserSession');
10+
},
11+
tracesSampleRate: 0,
12+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sentry.captureException(new Error('test error'));
2+
Sentry.captureException(new Error('test error 2'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012" />
6+
<meta
7+
name="baggage"
8+
content="sentry-release=2.1.12,sentry-public_key=public,sentry-trace_id=123"
9+
/>
10+
</head>
11+
</html>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/browser';
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers';
5+
6+
sentryTest('errors in TwP mode have same trace ID & span IDs', async ({ getLocalTestUrl, page }) => {
7+
if (shouldSkipTracingTest()) {
8+
sentryTest.skip();
9+
}
10+
11+
const traceId = '12312012123120121231201212312012';
12+
const spanId = '1121201211212012';
13+
14+
const url = await getLocalTestUrl({ testDir: __dirname });
15+
const [event1, event2] = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });
16+
17+
// Ensure these are the actual errors we care about
18+
expect(event1.exception?.values?.[0].value).toContain('test error');
19+
expect(event2.exception?.values?.[0].value).toContain('test error');
20+
21+
const contexts1 = event1.contexts;
22+
const { trace_id: traceId1, span_id: spanId1 } = contexts1?.trace || {};
23+
expect(traceId1).toEqual(traceId);
24+
25+
// Span ID is a virtual span, not the propagated one
26+
expect(spanId1).not.toEqual(spanId);
27+
expect(spanId1).toMatch(/^[a-f0-9]{16}$/);
28+
29+
const contexts2 = event2.contexts;
30+
const { trace_id: traceId2, span_id: spanId2 } = contexts2?.trace || {};
31+
expect(traceId2).toEqual(traceId);
32+
expect(spanId2).toMatch(/^[a-f0-9]{16}$/);
33+
34+
expect(spanId2).toEqual(spanId1);
35+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
integrations: integrations => {
8+
integrations.push(Sentry.browserTracingIntegration());
9+
return integrations.filter(i => i.name !== 'BrowserSession');
10+
},
11+
tracesSampleRate: 0,
12+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sentry.captureException(new Error('test error'));
2+
Sentry.captureException(new Error('test error 2'));
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/browser';
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers';
5+
6+
sentryTest('errors in TwP mode have same trace ID & span IDs', async ({ getLocalTestUrl, page }) => {
7+
if (shouldSkipTracingTest()) {
8+
sentryTest.skip();
9+
}
10+
11+
const url = await getLocalTestUrl({ testDir: __dirname });
12+
const [event1, event2] = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });
13+
14+
// Ensure these are the actual errors we care about
15+
expect(event1.exception?.values?.[0].value).toContain('test error');
16+
expect(event2.exception?.values?.[0].value).toContain('test error');
17+
18+
const contexts1 = event1.contexts;
19+
const { trace_id: traceId1, span_id: spanId1 } = contexts1?.trace || {};
20+
expect(traceId1).toMatch(/^[a-f0-9]{32}$/);
21+
expect(spanId1).toMatch(/^[a-f0-9]{16}$/);
22+
23+
const contexts2 = event2.contexts;
24+
const { trace_id: traceId2, span_id: spanId2 } = contexts2?.trace || {};
25+
expect(traceId2).toMatch(/^[a-f0-9]{32}$/);
26+
expect(spanId2).toMatch(/^[a-f0-9]{16}$/);
27+
28+
expect(traceId2).toEqual(traceId1);
29+
expect(spanId2).toEqual(spanId1);
30+
});

dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-root-spans/scenario.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Sentry.init({
1010

1111
Sentry.getCurrentScope().setPropagationContext({
1212
parentSpanId: '1234567890123456',
13-
spanId: '123456789012345x',
1413
traceId: '12345678901234567890123456789012',
1514
});
1615

dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/scenario.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Sentry.init({
1111
Sentry.withScope(scope => {
1212
scope.setPropagationContext({
1313
parentSpanId: '1234567890123456',
14-
spanId: '123456789012345x',
1514
traceId: '12345678901234567890123456789012',
1615
});
1716

0 commit comments

Comments
 (0)