diff --git a/CHANGELOG4.asciidoc b/CHANGELOG4.asciidoc index c6206e88b3..c8f23e1c23 100644 --- a/CHANGELOG4.asciidoc +++ b/CHANGELOG4.asciidoc @@ -39,6 +39,13 @@ * Add a warning message when a duration config option is provided without units. ({issues}2121[#2121]) +* Change default value of `useElasticTraceparentHeader` config option to `false`. + This means that for outgoing HTTP requests, the APM agent will no longer add the + `elastic-apm-traceparent` header. This vendor-specific header was used in the past + while the https://w3c.github.io/trace-context/[W3C trace-context] spec was still + in development. Now that it is in wide use, the `elastic-apm-traceparent` header is + only useful for interaction with very old Elastic APM agents. + [[release-notes-3.x]] === Node.js Agent version 3.x diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 77a24b1a9c..120976218f 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -1422,8 +1422,10 @@ The captured request body (if any) is stored on the `span.db.statement` field. C [[use-elastic-traceparent-header]] ==== `useElasticTraceparentHeader` +[small]#Change default in v4.0.0, in v3.x the default was `true`# + * *Type:* Boolean -* *Default:* `true` +* *Default:* `false` * *Env:* `ELASTIC_APM_USE_ELASTIC_TRACEPARENT_HEADER` To enable {apm-guide-ref}/apm-distributed-tracing.html[distributed tracing], the agent diff --git a/docs/upgrade-to-v4.asciidoc b/docs/upgrade-to-v4.asciidoc index 55b6afc0d0..2c91eee220 100644 --- a/docs/upgrade-to-v4.asciidoc +++ b/docs/upgrade-to-v4.asciidoc @@ -15,6 +15,7 @@ The following is a guide on upgrading your APM Node.js agent Version 4.0.0 of the Node.js APM agent supports Node.js v14.5.0 and later. + [[v4-config-options]] ==== Config options @@ -34,6 +35,17 @@ Support for `filterHttpHeaders` config option has been removed. Redaction of HTTP headers and also request cookies is controlled by the existing config option <>. +===== `useElasticTraceparentHeader` + +The default value of the <> config option has +changed to `false`. This means that the vendor-specific +`elastic-apm-traceparent` header will no longer be added to outgoing HTTP +requests. The `traceparent` header (from the +https://w3c.github.io/trace-context/[W3C trace-context standard]) is added by +the APM agent. If you want the agent to continue sending +`elastic-apm-traceparent` HTTP header you can set it to `true` via env var or +start options. + [[v4-api-changes]] ==== API changes diff --git a/lib/config/schema.js b/lib/config/schema.js index c0278e1428..0e8fe671f2 100644 --- a/lib/config/schema.js +++ b/lib/config/schema.js @@ -118,7 +118,7 @@ const DEFAULTS = { transactionIgnoreUrls: [], transactionMaxSpans: 500, transactionSampleRate: 1.0, - useElasticTraceparentHeader: true, + useElasticTraceparentHeader: false, usePathAsTransactionName: false, verifyServerCert: true, }; diff --git a/test/instrumentation/modules/http/outgoing.test.js b/test/instrumentation/modules/http/outgoing.test.js index 53ce2671b3..0d663fe401 100644 --- a/test/instrumentation/modules/http/outgoing.test.js +++ b/test/instrumentation/modules/http/outgoing.test.js @@ -57,7 +57,7 @@ test( test( 'http: consider useElasticTraceparentHeader config option', - echoTest('http', { useElasticTraceparentHeader: false }, (port, cb) => { + echoTest('http', { useElasticTraceparentHeader: true }, (port, cb) => { var options = { port }; return http.request(options, cb); }), @@ -364,13 +364,13 @@ function echoTest(type, opts, handler) { var traceparent = req.getHeader('traceparent'); t.ok(traceparent, 'should have traceparent header'); - if (opts && opts.useElasticTraceparentHeader === false) { - t.strictEqual(req.getHeader('elastic-apm-traceparent'), undefined); - } else { + if (opts && opts.useElasticTraceparentHeader) { t.ok( req.getHeader('elastic-apm-traceparent'), 'should have elastic-apm-traceparent header', ); + } else { + t.strictEqual(req.getHeader('elastic-apm-traceparent'), undefined); } var expected = TraceParent.fromString(trans._context.toString()); diff --git a/test/instrumentation/modules/http2.test.js b/test/instrumentation/modules/http2.test.js index 0acb96bc47..f9831683b8 100644 --- a/test/instrumentation/modules/http2.test.js +++ b/test/instrumentation/modules/http2.test.js @@ -602,8 +602,6 @@ function assertPath(t, trans, secure, port, path, httpVersion) { if (trans.context.request.headers.traceparent) { expectedReqHeaders.traceparent = trans.context.request.headers.traceparent; expectedReqHeaders.tracestate = trans.context.request.headers.tracestate; - expectedReqHeaders['elastic-apm-traceparent'] = - trans.context.request.headers['elastic-apm-traceparent']; } // What is "expected" for transaction.context.request.socket.remote_address diff --git a/test/opentelemetry-bridge/fixtures.test.js b/test/opentelemetry-bridge/fixtures.test.js index c182a6f789..f174f9eeb2 100644 --- a/test/opentelemetry-bridge/fixtures.test.js +++ b/test/opentelemetry-bridge/fixtures.test.js @@ -263,10 +263,6 @@ const cases = [ trans.context.request.headers.traceparent, 'incoming http "traceparent" header', ); - t.ok( - trans.context.request.headers['elastic-apm-traceparent'], - 'incoming http "elastic-apm-traceparent" header', - ); t.ok( (trans.context.request.headers.tracestate || '').indexOf('es=s:1') !== -1, diff --git a/test/tracecontext/tracecontext.test.js b/test/tracecontext/tracecontext.test.js index a26d851586..34f547e83b 100644 --- a/test/tracecontext/tracecontext.test.js +++ b/test/tracecontext/tracecontext.test.js @@ -45,13 +45,13 @@ tape.test('propagateTraceContextHeaders tests', function (suite) { span.end(); transaction.end(); - t.equals(span._context.traceparent.toString(), newHeaders.traceparent); - t.equals(traceStateString, newHeaders.tracestate); t.equals( span._context.traceparent.toString(), - newHeaders['elastic-apm-traceparent'], + newHeaders.traceparent, + 'traceparent', ); - t.true(span._hasPropagatedTraceContext); + t.equals(traceStateString, newHeaders.tracestate, 'tracestate'); + t.true(span._hasPropagatedTraceContext, '_hasPropagatedTraceContext'); t.end(); });