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
[

0 commit comments

Comments
 (0)