From 7aa5f4b87e07fc5d1d804aeae1eaea173fdb33c6 Mon Sep 17 00:00:00 2001 From: Arya <90748009+aryamohanan@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:15:05 +0530 Subject: [PATCH] fix: dropped support for x-instana-service header (#1355) BREAKING CHANGE: - Migration: Please configure the Instana agent to capture the X-Instana-Service header in the agent's configuration file. - For details, see: https://www.ibm.com/docs/en/instana-observability/current?topic=applications-services#specify-the-x-instana-service-http-header. --- .../collector/test/tracing/common/test.js | 23 ------------------- .../test/tracing/protocols/http2/test.js | 21 +---------------- packages/core/src/tracing/constants.js | 3 --- .../instrumentation/protocols/http2Server.js | 6 ----- .../instrumentation/protocols/httpServer.js | 6 ----- 5 files changed, 1 insertion(+), 58 deletions(-) diff --git a/packages/collector/test/tracing/common/test.js b/packages/collector/test/tracing/common/test.js index d9b5d68af6..516dce198d 100644 --- a/packages/collector/test/tracing/common/test.js +++ b/packages/collector/test/tracing/common/test.js @@ -168,23 +168,6 @@ mochaSuiteFn('tracing/common', function () { ); }); - describe('with header when agent is configured to capture the header', function () { - const agentControls = new AgentStubControls(); - const agentConfig = { extraHeaders: ['x-iNsTanA-sErViCe'] }; - - before(async () => { - await agentControls.startAgent(agentConfig); - }); - after(async () => { - await agentControls.stopAgent(); - }); - - registerServiceNameTest.call(this, agentControls, { - configMethod: 'X-Instana-Service header', - expectServiceNameOnSpans: 'on-entry-span' - }); - }); - describe('with header when agent is _not_ configured to capture the header', function () { const agentControls = new AgentStubControls(); @@ -196,7 +179,6 @@ mochaSuiteFn('tracing/common', function () { }); registerServiceNameTest.call(this, agentControls, { - configMethod: 'X-Instana-Service header', expectServiceNameOnSpans: 'no' }); }); @@ -236,11 +218,6 @@ mochaSuiteFn('tracing/common', function () { const req = { path: '/with-intermediate-and-exit-spans' }; - if (configMethod === 'X-Instana-Service header') { - req.headers = { - 'x-InsTana-sErvice': 'much-custom-very-wow service' - }; - } return controls.sendRequest(req).then(() => verifyServiceName(agentControls, expectServiceNameOnSpans)); }); } diff --git a/packages/collector/test/tracing/protocols/http2/test.js b/packages/collector/test/tracing/protocols/http2/test.js index 399f3c4d44..fdf1a074d6 100644 --- a/packages/collector/test/tracing/protocols/http2/test.js +++ b/packages/collector/test/tracing/protocols/http2/test.js @@ -30,8 +30,7 @@ mochaSuiteFn('tracing/http2', function () { extraHeaders: [ // 'X-My-Request-Header', - 'X-My-Response-Header', - 'x-iNsTanA-sErViCe' + 'X-My-Response-Header' ], secretsList: ['remove'] }); @@ -210,24 +209,6 @@ mochaSuiteFn('tracing/http2', function () { ) )); - it('must use x-service-service', () => - serverControls - .sendRequest({ - method: 'GET', - path: '/request', - headers: { - 'x-instanA-SERVICE': 'Custom Service' - } - }) - .then(() => - retry(() => - agentControls.getSpans().then(spans => { - const entry = verifyRootHttpEntry(spans, `localhost:${serverControls.getPort()}`, '/request'); - expect(entry.data.service).to.equal('Custom Service'); - }) - ) - )); - describe('Server-Timing header', () => { it('must expose trace id as Server-Timing header', () => serverControls diff --git a/packages/core/src/tracing/constants.js b/packages/core/src/tracing/constants.js index 2624e0dac4..9efe68339c 100644 --- a/packages/core/src/tracing/constants.js +++ b/packages/core/src/tracing/constants.js @@ -38,9 +38,6 @@ exports.w3cTraceState = 'tracestate'; exports.w3cInstana = 'in'; exports.w3cInstanaEquals = `${exports.w3cInstana}=`; -exports.serviceNameHeaderName = 'X-Instana-Service'; -exports.serviceNameHeaderNameLowerCase = exports.serviceNameHeaderName.toLowerCase(); - exports.ENTRY = 1; exports.EXIT = 2; exports.INTERMEDIATE = 3; diff --git a/packages/core/src/tracing/instrumentation/protocols/http2Server.js b/packages/core/src/tracing/instrumentation/protocols/http2Server.js index 4166d47b1d..c779fde2cc 100644 --- a/packages/core/src/tracing/instrumentation/protocols/http2Server.js +++ b/packages/core/src/tracing/instrumentation/protocols/http2Server.js @@ -131,12 +131,6 @@ function shimEmit(realEmit) { header: getExtraHeadersFromNormalizedObjectLiteral(headers, extraHttpHeadersToCapture) }; - const incomingServiceName = - span.data.http.header && span.data.http.header[constants.serviceNameHeaderNameLowerCase]; - if (incomingServiceName != null) { - span.data.service = incomingServiceName; - } - if (!headers['x-instana-t']) { // In cases where we have started a fresh trace (that is, there is no X-INSTANA-T in the incoming request // headers, we add the new trace ID to the incoming request so a customer's app can render it reliably into the diff --git a/packages/core/src/tracing/instrumentation/protocols/httpServer.js b/packages/core/src/tracing/instrumentation/protocols/httpServer.js index 13c114d562..cefe84176d 100644 --- a/packages/core/src/tracing/instrumentation/protocols/httpServer.js +++ b/packages/core/src/tracing/instrumentation/protocols/httpServer.js @@ -104,12 +104,6 @@ function shimEmit(realEmit) { header: getExtraHeadersFromMessage(req, extraHttpHeadersToCapture) }; - const incomingServiceName = - span.data.http.header && span.data.http.header[constants.serviceNameHeaderNameLowerCase]; - if (incomingServiceName != null) { - span.data.service = incomingServiceName; - } - if (!req.headers['x-instana-t']) { // In cases where we have started a fresh trace (that is, there is no X-INSTANA-T in the incoming request // headers, we add the new trace ID to the incoming request so a customer's app can render it reliably into the