Skip to content

Commit 99f6f92

Browse files
authored
fix(node-experimental): Ensure http.status_code is always a string (#10177)
Noticed here: #10168, tags should always be strings.
1 parent 5498a78 commit 99f6f92

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
6868
span_id: expect.any(String),
6969
status: 'ok',
7070
tags: {
71-
'http.status_code': 200,
71+
'http.status_code': '200',
7272
},
7373
trace_id: traceId,
7474
origin: 'auto.http.otel.http',
@@ -91,7 +91,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
9191
span_id: expect.any(String),
9292
status: 'ok',
9393
tags: {
94-
'http.status_code': 200,
94+
'http.status_code': '200',
9595
},
9696
trace_id: traceId,
9797
origin: 'auto.http.otel.http',
@@ -161,7 +161,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
161161
span_id: expect.any(String),
162162
status: 'ok',
163163
tags: {
164-
'http.status_code': 200,
164+
'http.status_code': '200',
165165
},
166166
trace_id: traceId,
167167
origin: 'auto.http.otel.http',
@@ -184,7 +184,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
184184
span_id: expect.any(String),
185185
status: 'ok',
186186
tags: {
187-
'http.status_code': 200,
187+
'http.status_code': '200',
188188
},
189189
trace_id: traceId,
190190
origin: 'auto.http.otel.http',

dev-packages/e2e-tests/test-applications/node-experimental-fastify-app/tests/transactions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
3333
span_id: expect.any(String),
3434
status: 'ok',
3535
tags: {
36-
'http.status_code': 200,
36+
'http.status_code': '200',
3737
},
3838
trace_id: expect.any(String),
3939
origin: 'auto.http.otel.http',
@@ -85,7 +85,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
8585
},
8686
],
8787
tags: {
88-
'http.status_code': 200,
88+
'http.status_code': '200',
8989
},
9090
transaction: 'GET /test-transaction',
9191
type: 'transaction',

packages/opentelemetry/src/spanExporter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ function getTags(span: ReadableSpan): Record<string, string> {
280280
const tags: Record<string, string> = {};
281281

282282
if (attributes[SemanticAttributes.HTTP_STATUS_CODE]) {
283-
const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] as string;
284-
285-
tags['http.status_code'] = statusCode;
283+
const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] as string | number;
284+
tags['http.status_code'] = `${statusCode}`;
286285
}
287286

288287
return tags;

0 commit comments

Comments
 (0)