Skip to content

test(nuxt): Add tests for trace baggage #16046

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 5 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small info when reviewing this: All the files have exactly the same changes :)

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ test.describe('distributed tracing', () => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
const res = await page.goto(`/test-param/${PARAM}`);
const data = await res.json();

const [clientTxnEvent, serverTxnEvent] = await Promise.all([
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
Expand All @@ -33,7 +35,7 @@ test.describe('distributed tracing', () => {
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction: `GET /test-param/${PARAM}`, // todo: parametrize (nitro)
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
Expand All @@ -44,8 +46,22 @@ test.describe('distributed tracing', () => {
},
});

const baggage = (data.headers.baggage || null).split(',');

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).not.toBeUndefined();
expect(clientTxnEvent.contexts?.trace?.parent_span_id).not.toBeUndefined();
expect(baggage).not.toBeNull();

expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
expect(baggage).toEqual(
expect.arrayContaining([
'sentry-sample-rate=1.0',
'sentry-sampled=true',
`sentry-trace_id=${serverTxnEvent.contexts?.trace?.trace_id}`,
`sentry-transaction=GET%20%2Ftest-param%2F${PARAM}`,
]),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ test.describe('distributed tracing', () => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
const res = await page.goto(`/test-param/${PARAM}`);
const data = await res.json();

const [clientTxnEvent, serverTxnEvent] = await Promise.all([
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
Expand All @@ -33,7 +35,7 @@ test.describe('distributed tracing', () => {
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction: `GET /test-param/${PARAM}`, // todo: parametrize (nitro)
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
Expand All @@ -44,8 +46,22 @@ test.describe('distributed tracing', () => {
},
});

const baggage = (data.headers.baggage || null).split(',');

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).not.toBeUndefined();
expect(clientTxnEvent.contexts?.trace?.parent_span_id).not.toBeUndefined();
expect(baggage).not.toBeNull();

expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
expect(baggage).toEqual(
expect.arrayContaining([
'sentry-sample-rate=1.0',
'sentry-sampled=true',
`sentry-trace_id=${serverTxnEvent.contexts?.trace?.trace_id}`,
`sentry-transaction=GET%20%2Ftest-param%2F${PARAM}`,
]),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ test.describe('distributed tracing', () => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
const res = await page.goto(`/test-param/${PARAM}`);
const data = await res.json();

const [clientTxnEvent, serverTxnEvent] = await Promise.all([
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
Expand All @@ -33,7 +35,7 @@ test.describe('distributed tracing', () => {
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction: `GET /test-param/${PARAM}`, // todo: parametrize (nitro)`
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
Expand All @@ -44,8 +46,22 @@ test.describe('distributed tracing', () => {
},
});

const baggage = (data.headers.baggage || null).split(',');

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).not.toBeUndefined();
expect(clientTxnEvent.contexts?.trace?.parent_span_id).not.toBeUndefined();
expect(baggage).not.toBeNull();

expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
expect(baggage).toEqual(
expect.arrayContaining([
'sentry-sample-rate=1.0',
'sentry-sampled=true',
`sentry-trace_id=${serverTxnEvent.contexts?.trace?.trace_id}`,
`sentry-transaction=GET%20%2Ftest-param%2F${PARAM}`,
]),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ test.describe('distributed tracing', () => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
const res = await page.goto(`/test-param/${PARAM}`);
const data = await res.json();

const [clientTxnEvent, serverTxnEvent] = await Promise.all([
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
Expand All @@ -33,7 +35,7 @@ test.describe('distributed tracing', () => {
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction: `GET /test-param/${PARAM}`, // todo: parametrize (nitro)
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
Expand All @@ -44,8 +46,22 @@ test.describe('distributed tracing', () => {
},
});

const baggage = (data.headers.baggage || null).split(',');

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).not.toBeUndefined();
expect(clientTxnEvent.contexts?.trace?.parent_span_id).not.toBeUndefined();
expect(baggage).not.toBeNull();

expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
expect(baggage).toEqual(
expect.arrayContaining([
'sentry-sample-rate=1.0',
'sentry-sampled=true',
`sentry-trace_id=${serverTxnEvent.contexts?.trace?.trace_id}`,
`sentry-transaction=GET%20%2Ftest-param%2F${PARAM}`,
]),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ test.describe('distributed tracing', () => {
return txnEvent.transaction.includes('GET /test-param/');
});

const [_, clientTxnEvent, serverTxnEvent] = await Promise.all([
page.goto(`/test-param/${PARAM}`),
const res = await page.goto(`/test-param/${PARAM}`);
const data = await res.json();

const [clientTxnEvent, serverTxnEvent] = await Promise.all([
clientTxnEventPromise,
serverTxnEventPromise,
expect(page.getByText(`Param: ${PARAM}`)).toBeVisible(),
Expand All @@ -33,7 +35,7 @@ test.describe('distributed tracing', () => {
});

expect(serverTxnEvent).toMatchObject({
transaction: 'GET /test-param/s0me-param', // todo: parametrize (nitro)
transaction: `GET /test-param/${PARAM}`, // todo: parametrize (nitro)
transaction_info: { source: 'url' },
type: 'transaction',
contexts: {
Expand All @@ -44,8 +46,22 @@ test.describe('distributed tracing', () => {
},
});

const baggage = (data.headers.baggage || null).split(',');

// connected trace
expect(clientTxnEvent.contexts?.trace?.trace_id).not.toBeUndefined();
expect(clientTxnEvent.contexts?.trace?.parent_span_id).not.toBeUndefined();
expect(baggage).not.toBeNull();

expect(clientTxnEvent.contexts?.trace?.trace_id).toBe(serverTxnEvent.contexts?.trace?.trace_id);
expect(clientTxnEvent.contexts?.trace?.parent_span_id).toBe(serverTxnEvent.contexts?.trace?.span_id);
expect(baggage).toEqual(
expect.arrayContaining([
'sentry-sample-rate=1.0',
'sentry-sampled=true',
`sentry-trace_id=${serverTxnEvent.contexts?.trace?.trace_id}`,
`sentry-transaction=GET%20%2Ftest-param%2F${PARAM}`,
]),
);
});
});
Loading