Skip to content

test: Ensure we properly test trace & span IDs #14520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ sentryTest('allows to setup a client manually & capture exceptions', async ({ ge
version: expect.any(String),
packages: [{ name: expect.any(String), version: expect.any(String) }],
},
contexts: { trace: { trace_id: expect.any(String), span_id: expect.any(String) } },
contexts: {
trace: { trace_id: expect.stringMatching(/[a-f0-9]{32}/), span_id: expect.stringMatching(/[a-f0-9]{16}/) },
},
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sentryTest(
expect(envHeader.trace).toEqual({
environment: 'production',
sample_rate: '1',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
replay_id: replay.session?.id,
sampled: 'true',
Expand Down Expand Up @@ -105,7 +105,7 @@ sentryTest(
expect(envHeader.trace).toEqual({
environment: 'production',
sample_rate: '1',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
sampled: 'true',
});
Expand Down Expand Up @@ -157,7 +157,7 @@ sentryTest(
expect(envHeader.trace).toEqual({
environment: 'production',
sample_rate: '1',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
replay_id: replay.session?.id,
sampled: 'true',
Expand Down Expand Up @@ -199,7 +199,7 @@ sentryTest(
expect(envHeader.trace).toEqual({
environment: 'production',
sample_rate: '1',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
sampled: 'true',
});
Expand Down Expand Up @@ -240,7 +240,7 @@ sentryTest('should add replay_id to error DSC while replay is active', async ({
expect(error1Header.trace).toBeDefined();
expect(error1Header.trace).toEqual({
environment: 'production',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
replay_id: replay.session?.id,
...(hasTracing
Expand All @@ -261,7 +261,7 @@ sentryTest('should add replay_id to error DSC while replay is active', async ({
expect(error2Header.trace).toBeDefined();
expect(error2Header.trace).toEqual({
environment: 'production',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
...(hasTracing
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sentryTest('should create fetch spans with http timing @firefox', async ({ brows
expect(span).toMatchObject({
description: `GET http://example.com/${index}`,
parent_span_id: tracingEvent.contexts?.trace?.span_id,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: tracingEvent.contexts?.trace?.trace_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sentryTest(
environment: 'production',
sample_rate: '1',
transaction: expect.stringContaining('/index.html'),
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
sampled: 'true',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sentryTest(
expect(envHeader.trace).toEqual({
environment: 'production',
sample_rate: '1',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
public_key: 'public',
sampled: 'true',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, p
expect(span).toMatchObject({
description: `GET /test-req/${index}`,
parent_span_id: tracingEvent.contexts?.trace?.span_id,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: tracingEvent.contexts?.trace?.trace_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, p
expect(span).toMatchObject({
description: `GET http://example.com/${index}`,
parent_span_id: tracingEvent.contexts?.trace?.span_id,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: tracingEvent.contexts?.trace?.trace_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sentryTest('should create spans for xhr requests', async ({ getLocalTestUrl, pag
expect(span).toMatchObject({
description: `GET /test-req/${index}`,
parent_span_id: tracingEvent.contexts?.trace?.span_id,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: tracingEvent.contexts?.trace?.trace_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sentryTest('should create spans for XHR requests', async ({ getLocalTestUrl, pag
expect(span).toMatchObject({
description: `GET http://example.com/${index}`,
parent_span_id: eventData.contexts?.trace?.span_id,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: eventData.contexts?.trace?.trace_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ test('Lambda layer SDK bundle sends events', async ({ request }) => {
},
op: 'function.aws.lambda',
origin: 'auto.otel.aws-lambda',
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
});

expect(transactionEvent.spans).toHaveLength(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ test('AWS Serverless SDK sends events in ESM mode', async ({ request }) => {
},
op: 'function.aws.lambda',
origin: 'auto.function.serverless',
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
});

expect(transactionEvent.spans).toHaveLength(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('Sends a client-side exception to Sentry', async ({ page }) => {
expect(errorEvent.transaction).toEqual('/');

expect(errorEvent.contexts?.trace).toEqual({
trace_id: expect.any(String),
span_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
version: '18.2.0',
},
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
op: 'pageload',
origin: 'auto.pageload.nextjs.pages_router_instrumentation',
data: expect.objectContaining({
Expand Down Expand Up @@ -65,8 +65,8 @@ test('captures a navigation transcation to Sentry', async ({ page }) => {
version: '18.2.0',
},
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
op: 'navigation',
origin: 'auto.navigation.nextjs.pages_router_instrumentation',
data: expect.objectContaining({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('Sends a server-side exception to Sentry', async ({ baseURL }) => {
expect(errorEvent.transaction).toEqual('GET /api/error');

expect(errorEvent.contexts?.trace).toEqual({
trace_id: expect.any(String),
span_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ test('Sends server-side transactions to Sentry', async ({ baseURL }) => {
type: 'transaction',
contexts: expect.objectContaining({
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
op: 'http.server',
origin: 'auto.http.nextjs',
data: expect.objectContaining({
Expand All @@ -41,7 +41,7 @@ test('Sends server-side transactions to Sentry', async ({ baseURL }) => {
description: 'test-span',
origin: 'manual',
parent_span_id: transactionEvent.contexts?.trace?.span_id,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ test('sends an INP span during pageload', async ({ page }) => {
},
description: 'body > div > input#exception-button[type="button"]',
op: 'ui.interaction.click',
parent_span_id: expect.any(String),
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
is_segment: true,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
origin: 'auto.http.browser.inp',
exclusive_time: expect.any(Number),
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } },
Expand Down Expand Up @@ -86,12 +86,12 @@ test('sends an INP span after pageload', async ({ page }) => {
},
description: 'body > div > input#exception-button[type="button"]',
op: 'ui.interaction.click',
parent_span_id: expect.any(String),
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
is_segment: true,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
origin: 'auto.http.browser.inp',
exclusive_time: expect.any(Number),
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } },
Expand Down Expand Up @@ -131,11 +131,11 @@ test('sends an INP span during navigation', async ({ page }) => {
},
description: '<unknown>',
op: 'ui.interaction.click',
parent_span_id: expect.any(String),
span_id: expect.any(String),
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
origin: 'auto.http.browser.inp',
exclusive_time: expect.any(Number),
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } },
Expand Down Expand Up @@ -186,10 +186,10 @@ test('sends an INP span after navigation', async ({ page }) => {
description: '<unknown>',
op: 'ui.interaction.click',
is_segment: true,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
origin: 'auto.http.browser.inp',
exclusive_time: expect.any(Number),
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ test('captures an error', async ({ page }) => {
});

expect(errorEvent.contexts?.trace).toEqual({
trace_id: expect.any(String),
span_id: expect.any(String),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.transition',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -174,7 +174,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.route.before_model',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -189,7 +189,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.route.before_model',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -207,7 +207,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.route.model',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -222,7 +222,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.route.model',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -240,7 +240,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.route.after_model',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -255,7 +255,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.route.after_model',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand All @@ -271,7 +271,7 @@ test('captures correct spans for navigation', async ({ page }) => {
op: 'ui.ember.runloop.render',
origin: 'auto.ui.ember',
parent_span_id: spanId,
span_id: expect.any(String),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: traceId,
Expand Down
Loading
Loading