Skip to content
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

Add http.response.status_code to span.data #8366

Merged
merged 4 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/core/src/tracing/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export class Span implements SpanInterface {
*/
public setHttpStatus(httpStatus: number): this {
this.setTag('http.status_code', String(httpStatus));
this.setData('http.response.status_code', httpStatus);
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
const spanStatus = spanStatusfromHttpCode(httpStatus);
if (spanStatus !== 'unknown_error') {
this.setStatus(spanStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ describe('CommonJS API Endpoints', () => {
op: 'http.server',
status: 'ok',
tags: { 'http.status_code': '200' },
data: {
'http.response.status_code': 200,
},
},
},
transaction: `GET ${unwrappedRoute}`,
Expand Down Expand Up @@ -51,6 +54,9 @@ describe('CommonJS API Endpoints', () => {
op: 'http.server',
status: 'ok',
tags: { 'http.status_code': '200' },
data: {
'http.response.status_code': 200,
},
},
},
transaction: `GET ${wrappedRoute}`,
Expand Down Expand Up @@ -84,6 +90,9 @@ describe('CommonJS API Endpoints', () => {
op: 'http.server',
status: 'ok',
tags: { 'http.status_code': '200' },
data: {
'http.response.status_code': 200,
},
},
},
transaction: `GET ${route}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ describe('Error API Endpoints', () => {
op: 'http.server',
status: 'internal_error',
tags: { 'http.status_code': '500' },
data: {
'http.response.status_code': 500,
},
},
},
transaction: 'GET /api/error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ describe('Tracing 200', () => {
op: 'http.server',
status: 'ok',
tags: { 'http.status_code': '200' },
data: {
'http.response.status_code': 200,
},
},
},
transaction: 'GET /api/users',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ describe('Tracing 500', () => {
op: 'http.server',
status: 'internal_error',
tags: { 'http.status_code': '500' },
data: {
'http.response.status_code': 500,
},
},
},
transaction: 'GET /api/broken',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ describe('Tracing HTTP', () => {
op: 'http.server',
status: 'ok',
tags: { 'http.status_code': '200' },
data: {
'http.response.status_code': 200,
},
},
},
spans: [
Expand All @@ -28,6 +31,9 @@ describe('Tracing HTTP', () => {
op: 'http.client',
status: 'ok',
tags: { 'http.status_code': '200' },
data: {
'http.response.status_code': 200,
},
},
],
transaction: 'GET /api/http',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test('should create and send transactions for Express routes and spans for middl
trace: {
data: {
url: '/test/express',
'http.response.status_code': 200,
},
op: 'http.server',
status: 'ok',
Expand Down Expand Up @@ -43,6 +44,7 @@ test('should set a correct transaction name for routes specified in RegEx', asyn
trace: {
data: {
url: '/test/regex',
'http.response.status_code': 200,
},
op: 'http.server',
status: 'ok',
Expand Down Expand Up @@ -71,6 +73,7 @@ test.each([['array1'], ['array5']])(
trace: {
data: {
url: `/test/${segment}`,
'http.response.status_code': 200,
},
op: 'http.server',
status: 'ok',
Expand Down Expand Up @@ -107,6 +110,7 @@ test.each([
trace: {
data: {
url: `/test/${segment}`,
'http.response.status_code': 200,
},
op: 'http.server',
status: 'ok',
Expand Down
1 change: 1 addition & 0 deletions packages/node/test/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ describe('tracingHandler', () => {
expect(finishTransaction).toHaveBeenCalled();
expect(transaction.status).toBe('ok');
expect(transaction.tags).toEqual(expect.objectContaining({ 'http.status_code': '200' }));
expect(transaction.data).toEqual(expect.objectContaining({ 'http.response.status_code': 200 }));
done();
});
});
Expand Down
21 changes: 21 additions & 0 deletions packages/remix/test/integration/test/server/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
tags: {
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
});
Expand Down Expand Up @@ -158,6 +161,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
method: 'POST',
'http.status_code': '302',
},
data: {
'http.response.status_code': 302,
},
},
},
tags: {
Expand All @@ -174,6 +180,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
method: 'GET',
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
tags: {
Expand Down Expand Up @@ -224,6 +233,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
method: 'POST',
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
tags: {
Expand Down Expand Up @@ -274,6 +286,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
method: 'POST',
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
tags: {
Expand Down Expand Up @@ -324,6 +339,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
method: 'POST',
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
tags: {
Expand Down Expand Up @@ -374,6 +392,9 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
method: 'POST',
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
tags: {
Expand Down
9 changes: 9 additions & 0 deletions packages/remix/test/integration/test/server/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
tags: {
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
});
Expand Down Expand Up @@ -95,6 +98,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
method: 'GET',
'http.status_code': '302',
},
data: {
'http.response.status_code': 302,
},
},
},
tags: {
Expand All @@ -111,6 +117,9 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
method: 'GET',
'http.status_code': '500',
},
data: {
'http.response.status_code': 500,
},
},
},
tags: {
Expand Down
1 change: 1 addition & 0 deletions packages/replay/test/fixtures/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function Transaction(traceId?: string, obj?: Partial<Event>): any {
method: 'GET',
url: '/api/0/projects/sentry-emerging-tech/billy-test/replays/c11bd625b0e14081a0827a22a0a9be4e/',
type: 'fetch',
'http.response.status_code': 200,
},
description: 'GET /api/0/projects/sentry-emerging-tech/billy-test/replays/c11bd625b0e14081a0827a22a0a9be4e/',
op: 'http.client',
Expand Down
1 change: 1 addition & 0 deletions packages/tracing/test/span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('Span', () => {
span.setHttpStatus(404);
expect((span.getTraceContext() as any).status).toBe('not_found');
expect(span.tags['http.status_code']).toBe('404');
expect(span.data['http.response.status_code']).toBe(404);
});

test('isSuccess', () => {
Expand Down
Loading