Skip to content

Commit a130579

Browse files
committed
fix some tests
1 parent 81ec187 commit a130579

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

dev-packages/e2e-tests/test-applications/node-express/tests/transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
1414
const transactionEvent = await pageloadTransactionEventPromise;
1515

1616
expect(transactionEvent.contexts?.trace).toEqual({
17-
data: {
17+
data: expect.objectContaining({
1818
'sentry.source': 'route',
1919
'sentry.origin': 'auto.http.otel.http',
2020
'sentry.op': 'http.server',
@@ -38,7 +38,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
3838
'http.status_code': 200,
3939
'http.status_text': 'OK',
4040
'http.route': '/test-transaction',
41-
},
41+
}),
4242
op: 'http.server',
4343
span_id: expect.stringMatching(/[a-f0-9]{16}/),
4444
status: 'ok',

dev-packages/e2e-tests/test-applications/node-fastify-5/tests/propagation.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
5151
);
5252

5353
expect(outboundTransaction.contexts?.trace).toEqual({
54-
data: {
54+
data: expect.objectContaining({
5555
'sentry.source': 'route',
5656
'sentry.origin': 'auto.http.otel.http',
5757
'sentry.op': 'http.server',
@@ -75,7 +75,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
7575
'http.status_code': 200,
7676
'http.status_text': 'OK',
7777
'http.route': '/test-outgoing-http/:id',
78-
},
78+
}),
7979
op: 'http.server',
8080
span_id: expect.stringMatching(/[a-f0-9]{16}/),
8181
status: 'ok',
@@ -84,7 +84,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
8484
});
8585

8686
expect(inboundTransaction.contexts?.trace).toEqual({
87-
data: {
87+
data: expect.objectContaining({
8888
'sentry.source': 'route',
8989
'sentry.origin': 'auto.http.otel.http',
9090
'sentry.op': 'http.server',
@@ -106,7 +106,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
106106
'http.status_code': 200,
107107
'http.status_text': 'OK',
108108
'http.route': '/test-inbound-headers/:id',
109-
},
109+
}),
110110
op: 'http.server',
111111
parent_span_id: outgoingHttpSpanId,
112112
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -165,7 +165,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
165165
);
166166

167167
expect(outboundTransaction.contexts?.trace).toEqual({
168-
data: {
168+
data: expect.objectContaining({
169169
'sentry.source': 'route',
170170
'sentry.origin': 'auto.http.otel.http',
171171
'sentry.op': 'http.server',
@@ -189,7 +189,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
189189
'http.status_code': 200,
190190
'http.status_text': 'OK',
191191
'http.route': '/test-outgoing-fetch/:id',
192-
},
192+
}),
193193
op: 'http.server',
194194
span_id: expect.stringMatching(/[a-f0-9]{16}/),
195195
status: 'ok',

dev-packages/e2e-tests/test-applications/node-koa/tests/propagation.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
5050
);
5151

5252
expect(outboundTransaction.contexts?.trace).toEqual({
53-
data: {
53+
data: expect.objectContaining({
5454
'sentry.source': 'route',
5555
'sentry.origin': 'auto.http.otel.http',
5656
'sentry.op': 'http.server',
@@ -74,7 +74,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
7474
'http.status_code': 200,
7575
'http.status_text': 'OK',
7676
'http.route': '/test-outgoing-http/:id',
77-
},
77+
}),
7878
op: 'http.server',
7979
span_id: expect.stringMatching(/[a-f0-9]{16}/),
8080
status: 'ok',
@@ -83,7 +83,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
8383
});
8484

8585
expect(inboundTransaction.contexts?.trace).toEqual({
86-
data: {
86+
data: expect.objectContaining({
8787
'sentry.source': 'route',
8888
'sentry.origin': 'auto.http.otel.http',
8989
'sentry.op': 'http.server',
@@ -105,7 +105,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
105105
'http.status_code': 200,
106106
'http.status_text': 'OK',
107107
'http.route': '/test-inbound-headers/:id',
108-
},
108+
}),
109109
op: 'http.server',
110110
parent_span_id: outgoingHttpSpanId,
111111
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -164,7 +164,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
164164
);
165165

166166
expect(outboundTransaction.contexts?.trace).toEqual({
167-
data: {
167+
data: expect.objectContaining({
168168
'sentry.source': 'route',
169169
'sentry.origin': 'auto.http.otel.http',
170170
'sentry.op': 'http.server',
@@ -188,7 +188,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
188188
'http.status_code': 200,
189189
'http.status_text': 'OK',
190190
'http.route': '/test-outgoing-fetch/:id',
191-
},
191+
}),
192192
op: 'http.server',
193193
span_id: expect.stringMatching(/[a-f0-9]{16}/),
194194
status: 'ok',

dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { afterAll, describe, expect, test } from 'vitest';
22
import { cleanupChildProcesses, createEsmAndCjsTests, createRunner } from '../../../utils/runner';
33
import { createTestServer } from '../../../utils/server';
44

5+
function getCommonHttpRequestHeaders(): Record<string, unknown> {
6+
return {
7+
'http.request.header.accept': ['*/*'],
8+
'http.request.header.accept_encoding': ['gzip, deflate'],
9+
'http.request.header.accept_language': ['*'],
10+
'http.request.header.connection': ['keep-alive'],
11+
'http.request.header.host': [expect.any(String)],
12+
'http.request.header.sec_fetch_mode': ['cors'],
13+
'http.request.header.user_agent': ['node'],
14+
};
15+
}
16+
517
describe('httpIntegration', () => {
618
afterAll(() => {
719
cleanupChildProcesses();
@@ -86,6 +98,7 @@ describe('httpIntegration', () => {
8698
'sentry.sample_rate': 1,
8799
'sentry.source': 'route',
88100
url: `http://localhost:${port}/test`,
101+
...getCommonHttpRequestHeaders(),
89102
});
90103
},
91104
})
@@ -127,6 +140,9 @@ describe('httpIntegration', () => {
127140
'sentry.sample_rate': 1,
128141
'sentry.source': 'route',
129142
url: `http://localhost:${port}/test`,
143+
'http.request.header.content_length': ['9'],
144+
'http.request.header.content_type': ['text/plain;charset=UTF-8'],
145+
...getCommonHttpRequestHeaders(),
130146
});
131147
},
132148
})

packages/cloudflare/test/request.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ describe('withSentry', () => {
319319
'sentry.sample_rate': 1,
320320
'http.response.status_code': 200,
321321
'http.request.body.size': 10,
322+
'http.request.header.content_length': ['10'],
322323
},
323324
op: 'http.server',
324325
origin: 'auto.http.cloudflare',

packages/core/src/utils/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function getAbsoluteUrl({
129129
}
130130

131131
/**
132-
* Converts HTTP request headers to OpenTelemetry span attributes following semantic conventions.
132+
* Converts incoming HTTP request headers to OpenTelemetry span attributes following semantic conventions.
133133
* Header names are converted to the format: http.request.header.<key>
134134
* where <key> is the header name in lowercase with dashes converted to underscores.
135135
*

0 commit comments

Comments
 (0)