Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 @@ -38,6 +38,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-outgoing-http/:id',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': ['localhost:3030'],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down Expand Up @@ -103,6 +110,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'nestjs.controller': 'AppController',
'nestjs.callback': 'testTransaction',
url: '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
description: 'GET /test-transaction',
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction from module', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/example-module/transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction from module', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/example-module/transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,33 @@ test('App router transactions should be attached to the pageload request span',
expect(pageloadTraceId).toBeTruthy();
expect(serverTransaction.contexts?.trace?.trace_id).toBe(pageloadTraceId);
});

test('extracts HTTP request headers as span attributes', async ({ baseURL }) => {
const serverTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => {
return transactionEvent?.transaction === 'GET /pageload-tracing';
});

await fetch(`${baseURL}/pageload-tracing`, {
headers: {
'User-Agent': 'Custom-NextJS-Agent/15.0',
'Content-Type': 'text/html',
'X-NextJS-Test': 'nextjs-header-value',
Accept: 'text/html, application/xhtml+xml',
'X-Framework': 'Next.js',
'X-Request-ID': 'nextjs-789',
},
});

const serverTransaction = await serverTransactionPromise;

expect(serverTransaction.contexts?.trace?.data).toEqual(
expect.objectContaining({
'http.request.header.user_agent': ['Custom-NextJS-Agent/15.0'],
'http.request.header.content_type': ['text/html'],
'http.request.header.x_nextjs_test': ['nextjs-header-value'],
'http.request.header.accept': ['text/html, application/xhtml+xml'],
'http.request.header.x_framework': ['Next.js'],
'http.request.header.x_request_id': ['nextjs-789'],
}),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ test('Sends a sampled API route transaction', async ({ baseURL }) => {
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': ['localhost:3030'],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
origin: 'manual',
op: 'http.server',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ test('Sends a sampled API route transaction', async ({ baseURL }) => {
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': ['localhost:3030'],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
origin: 'manual',
op: 'http.server',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
const transactionEvent = await pageloadTransactionEventPromise;

expect(transactionEvent.contexts?.trace).toEqual({
data: {
data: expect.objectContaining({
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
Expand All @@ -38,7 +38,14 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
},
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
}),
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
Expand Down Expand Up @@ -208,3 +215,34 @@ test('Sends an API route transaction for an errored route', async ({ baseURL })
measurements: {},
});
});

test('Extracts HTTP request headers as span attributes', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('node-express', transactionEvent => {
return (
transactionEvent?.contexts?.trace?.op === 'http.server' &&
transactionEvent?.transaction === 'GET /test-transaction'
);
});

await fetch(`${baseURL}/test-transaction`, {
headers: {
'User-Agent': 'Custom-Agent/1.0 (Test)',
'Content-Type': 'application/json',
'X-Custom-Header': 'test-value',
Accept: 'application/json, text/plain',
'X-Request-ID': 'req-123',
},
});

const transactionEvent = await transactionEventPromise;

expect(transactionEvent.contexts?.trace?.data).toEqual(
expect.objectContaining({
'http.request.header.user_agent': ['Custom-Agent/1.0 (Test)'],
'http.request.header.content_type': ['application/json'],
'http.request.header.x_custom_header': ['test-value'],
'http.request.header.accept': ['application/json, text/plain'],
'http.request.header.x_request_id': ['req-123'],
}),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-outgoing-http/:id',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': ['localhost:3030'],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down Expand Up @@ -106,6 +113,10 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-inbound-headers/:id',
'http.request.header.baggage': [expect.any(String)],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sentry_trace': [expect.stringContaining(traceId || '')],
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we also add the baggage and sentry_trace headers?

Copy link
Member

Choose a reason for hiding this comment

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

If this is a general question, not related to this test, then yes please. All request headers 😄

},
op: 'http.server',
parent_span_id: outgoingHttpSpanId,
Expand Down Expand Up @@ -189,6 +200,13 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-outgoing-fetch/:id',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ test('Sends an API route transaction', async ({ baseURL }) => {
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
'http.request.header.accept': ['*/*'],
'http.request.header.accept_encoding': ['gzip, deflate'],
'http.request.header.accept_language': ['*'],
'http.request.header.connection': ['keep-alive'],
'http.request.header.host': [expect.any(String)],
'http.request.header.sec_fetch_mode': ['cors'],
'http.request.header.user_agent': ['node'],
},
op: 'http.server',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
Expand Down
Loading
Loading