Skip to content

Commit be52259

Browse files
authored
fix: remove setting http.route in http span attributes (#2494)
1 parent f0dc893 commit be52259

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

experimental/packages/opentelemetry-instrumentation-http/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ export const getIncomingRequestAttributes = (
453453
}
454454

455455
if (requestUrl) {
456-
attributes[SemanticAttributes.HTTP_ROUTE] = requestUrl.pathname || '/';
457456
attributes[SemanticAttributes.HTTP_TARGET] = requestUrl.pathname || '/';
458457
}
459458

experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,21 @@ describe('Utility', () => {
466466
});
467467
});
468468

469+
describe('getIncomingRequestAttributes()', () => {
470+
it('should not set http.route in http span attributes', () => {
471+
const request = {
472+
url: 'http://hostname/user/:id',
473+
method: 'GET'
474+
} as IncomingMessage;
475+
request.headers = {
476+
'user-agent': 'chrome',
477+
'x-forwarded-for': '<client>, <proxy1>, <proxy2>'
478+
}
479+
const attributes = utils.getIncomingRequestAttributes(request, { component: 'http'})
480+
assert.strictEqual(attributes[SemanticAttributes.HTTP_ROUTE], undefined)
481+
});
482+
});
483+
469484
describe('headers to span attributes capture', () => {
470485
let span: Span;
471486

0 commit comments

Comments
 (0)