Skip to content

Commit da295ff

Browse files
Add http.response.status_code to span.data (#8366)
1 parent b3ee89e commit da295ff

File tree

14 files changed

+71
-8
lines changed

14 files changed

+71
-8
lines changed

packages/core/src/tracing/span.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export class Span implements SpanInterface {
227227
*/
228228
public setHttpStatus(httpStatus: number): this {
229229
this.setTag('http.status_code', String(httpStatus));
230+
this.setData('http.response.status_code', httpStatus);
230231
const spanStatus = spanStatusfromHttpCode(httpStatus);
231232
if (spanStatus !== 'unknown_error') {
232233
this.setStatus(spanStatus);

packages/nextjs/test/integration/test/client/tracingFetch.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ test('should correctly instrument `fetch` for performance tracing', async ({ pag
3636
url: 'http://example.com',
3737
type: 'fetch',
3838
'http.response_content_length': expect.any(Number),
39+
'http.response.status_code': 200,
3940
},
4041
description: 'GET http://example.com',
4142
op: 'http.client',

packages/nextjs/test/integration/test/server/cjsApiEndpoints.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ describe('CommonJS API Endpoints', () => {
1818
op: 'http.server',
1919
status: 'ok',
2020
tags: { 'http.status_code': '200' },
21+
data: {
22+
'http.response.status_code': 200,
23+
},
2124
},
2225
},
2326
transaction: `GET ${unwrappedRoute}`,
@@ -51,6 +54,9 @@ describe('CommonJS API Endpoints', () => {
5154
op: 'http.server',
5255
status: 'ok',
5356
tags: { 'http.status_code': '200' },
57+
data: {
58+
'http.response.status_code': 200,
59+
},
5460
},
5561
},
5662
transaction: `GET ${wrappedRoute}`,
@@ -84,6 +90,9 @@ describe('CommonJS API Endpoints', () => {
8490
op: 'http.server',
8591
status: 'ok',
8692
tags: { 'http.status_code': '200' },
93+
data: {
94+
'http.response.status_code': 200,
95+
},
8796
},
8897
},
8998
transaction: `GET ${route}`,

packages/nextjs/test/integration/test/server/errorApiEndpoint.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ describe('Error API Endpoints', () => {
4545
op: 'http.server',
4646
status: 'internal_error',
4747
tags: { 'http.status_code': '500' },
48+
data: {
49+
'http.response.status_code': 500,
50+
},
4851
},
4952
},
5053
transaction: 'GET /api/error',

packages/nextjs/test/integration/test/server/tracing200.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ describe('Tracing 200', () => {
1616
op: 'http.server',
1717
status: 'ok',
1818
tags: { 'http.status_code': '200' },
19+
data: {
20+
'http.response.status_code': 200,
21+
},
1922
},
2023
},
2124
transaction: 'GET /api/users',

packages/nextjs/test/integration/test/server/tracing500.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ describe('Tracing 500', () => {
1616
op: 'http.server',
1717
status: 'internal_error',
1818
tags: { 'http.status_code': '500' },
19+
data: {
20+
'http.response.status_code': 500,
21+
},
1922
},
2023
},
2124
transaction: 'GET /api/broken',

packages/nextjs/test/integration/test/server/tracingHttp.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ describe('Tracing HTTP', () => {
2020
op: 'http.server',
2121
status: 'ok',
2222
tags: { 'http.status_code': '200' },
23+
data: {
24+
'http.response.status_code': 200,
25+
},
2326
},
2427
},
2528
spans: [
@@ -28,6 +31,9 @@ describe('Tracing HTTP', () => {
2831
op: 'http.client',
2932
status: 'ok',
3033
tags: { 'http.status_code': '200' },
34+
data: {
35+
'http.response.status_code': 200,
36+
},
3137
},
3238
],
3339
transaction: 'GET /api/http',

packages/node-integration-tests/suites/express/tracing/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test('should create and send transactions for Express routes and spans for middl
1111
trace: {
1212
data: {
1313
url: '/test/express',
14+
'http.response.status_code': 200,
1415
},
1516
op: 'http.server',
1617
status: 'ok',
@@ -43,6 +44,7 @@ test('should set a correct transaction name for routes specified in RegEx', asyn
4344
trace: {
4445
data: {
4546
url: '/test/regex',
47+
'http.response.status_code': 200,
4648
},
4749
op: 'http.server',
4850
status: 'ok',
@@ -71,6 +73,7 @@ test.each([['array1'], ['array5']])(
7173
trace: {
7274
data: {
7375
url: `/test/${segment}`,
76+
'http.response.status_code': 200,
7477
},
7578
op: 'http.server',
7679
status: 'ok',
@@ -107,6 +110,7 @@ test.each([
107110
trace: {
108111
data: {
109112
url: `/test/${segment}`,
113+
'http.response.status_code': 200,
110114
},
111115
op: 'http.server',
112116
status: 'ok',

packages/node/test/handlers.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ describe('tracingHandler', () => {
351351
expect(finishTransaction).toHaveBeenCalled();
352352
expect(transaction.status).toBe('ok');
353353
expect(transaction.tags).toEqual(expect.objectContaining({ 'http.status_code': '200' }));
354+
expect(transaction.data).toEqual(expect.objectContaining({ 'http.response.status_code': 200 }));
354355
done();
355356
});
356357
});

packages/node/test/integrations/undici.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ conditionalTest({ min: 16 })('Undici integration', () => {
5656
{
5757
description: 'GET http://localhost:18099/',
5858
op: 'http.client',
59-
data: {
59+
data: expect.objectContaining({
6060
'http.method': 'GET',
61-
},
61+
}),
6262
},
6363
],
6464
[
@@ -68,10 +68,10 @@ conditionalTest({ min: 16 })('Undici integration', () => {
6868
{
6969
description: 'GET http://localhost:18099/',
7070
op: 'http.client',
71-
data: {
71+
data: expect.objectContaining({
7272
'http.method': 'GET',
7373
'http.query': '?foo=bar',
74-
},
74+
}),
7575
},
7676
],
7777
[
@@ -80,9 +80,9 @@ conditionalTest({ min: 16 })('Undici integration', () => {
8080
{ method: 'POST' },
8181
{
8282
description: 'POST http://localhost:18099/',
83-
data: {
83+
data: expect.objectContaining({
8484
'http.method': 'POST',
85-
},
85+
}),
8686
},
8787
],
8888
[
@@ -91,9 +91,9 @@ conditionalTest({ min: 16 })('Undici integration', () => {
9191
{ method: 'POST' },
9292
{
9393
description: 'POST http://localhost:18099/',
94-
data: {
94+
data: expect.objectContaining({
9595
'http.method': 'POST',
96-
},
96+
}),
9797
},
9898
],
9999
[

packages/remix/test/integration/test/server/action.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
6565
tags: {
6666
'http.status_code': '500',
6767
},
68+
data: {
69+
'http.response.status_code': 500,
70+
},
6871
},
6972
},
7073
});
@@ -160,6 +163,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
160163
method: 'POST',
161164
'http.status_code': '302',
162165
},
166+
data: {
167+
'http.response.status_code': 302,
168+
},
163169
},
164170
},
165171
tags: {
@@ -176,6 +182,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
176182
method: 'GET',
177183
'http.status_code': '500',
178184
},
185+
data: {
186+
'http.response.status_code': 500,
187+
},
179188
},
180189
},
181190
tags: {
@@ -226,6 +235,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
226235
method: 'POST',
227236
'http.status_code': '500',
228237
},
238+
data: {
239+
'http.response.status_code': 500,
240+
},
229241
},
230242
},
231243
tags: {
@@ -276,6 +288,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
276288
method: 'POST',
277289
'http.status_code': '500',
278290
},
291+
data: {
292+
'http.response.status_code': 500,
293+
},
279294
},
280295
},
281296
tags: {
@@ -326,6 +341,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
326341
method: 'POST',
327342
'http.status_code': '500',
328343
},
344+
data: {
345+
'http.response.status_code': 500,
346+
},
329347
},
330348
},
331349
tags: {
@@ -376,6 +394,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
376394
method: 'POST',
377395
'http.status_code': '500',
378396
},
397+
data: {
398+
'http.response.status_code': 500,
399+
},
379400
},
380401
},
381402
tags: {

packages/remix/test/integration/test/server/loader.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
2323
tags: {
2424
'http.status_code': '500',
2525
},
26+
data: {
27+
'http.response.status_code': 500,
28+
},
2629
},
2730
},
2831
});
@@ -97,6 +100,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
97100
method: 'GET',
98101
'http.status_code': '302',
99102
},
103+
data: {
104+
'http.response.status_code': 302,
105+
},
100106
},
101107
},
102108
tags: {
@@ -113,6 +119,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
113119
method: 'GET',
114120
'http.status_code': '500',
115121
},
122+
data: {
123+
'http.response.status_code': 500,
124+
},
116125
},
117126
},
118127
tags: {

packages/replay/test/fixtures/transaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function Transaction(traceId?: string, obj?: Partial<Event>): any {
5959
method: 'GET',
6060
url: '/api/0/projects/sentry-emerging-tech/billy-test/replays/c11bd625b0e14081a0827a22a0a9be4e/',
6161
type: 'fetch',
62+
'http.response.status_code': 200,
6263
},
6364
description: 'GET /api/0/projects/sentry-emerging-tech/billy-test/replays/c11bd625b0e14081a0827a22a0a9be4e/',
6465
op: 'http.client',

packages/tracing/test/span.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ describe('Span', () => {
9696
span.setHttpStatus(404);
9797
expect((span.getTraceContext() as any).status).toBe('not_found');
9898
expect(span.tags['http.status_code']).toBe('404');
99+
expect(span.data['http.response.status_code']).toBe(404);
99100
});
100101

101102
test('isSuccess', () => {

0 commit comments

Comments
 (0)