diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/utils.ts b/experimental/packages/opentelemetry-instrumentation-http/src/utils.ts index a24ff6f12a..d7fc6efc9b 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 d530fac61c..3192168829 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts @@ -465,4 +465,19 @@ describe('Utility', () => { verifyValueInAttributes(attributes, undefined, 1200); }); }); + + 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) + }); + }) });