diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/utils.ts b/experimental/packages/opentelemetry-instrumentation-http/src/utils.ts index d7c3ff8376..4f8a03c7af 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/utils.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/utils.ts @@ -453,7 +453,6 @@ export const getIncomingRequestAttributes = ( } if (requestUrl) { - attributes[SemanticAttributes.HTTP_ROUTE] = requestUrl.pathname || '/'; attributes[SemanticAttributes.HTTP_TARGET] = requestUrl.pathname || '/'; } diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts index cde1aafdc7..7b8a2e8d1e 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts @@ -466,6 +466,21 @@ describe('Utility', () => { }); }); + describe('getIncomingRequestAttributes()', () => { + it('should not set http.route in http span attributes', () => { + const request = { + url: 'http://hostname/user/:id', + method: 'GET' + } as IncomingMessage; + request.headers = { + 'user-agent': 'chrome', + 'x-forwarded-for': ', , ' + } + const attributes = utils.getIncomingRequestAttributes(request, { component: 'http'}) + assert.strictEqual(attributes[SemanticAttributes.HTTP_ROUTE], undefined) + }); + }); + describe('headers to span attributes capture', () => { let span: Span;