Skip to content

Commit 3a6af67

Browse files
authored
fix: only send 'activation_method' to APM server >=8.7.1 (#3231)
This works around an issue in APM server 8.7.0 which had problems receiving metadata with activation_method. Closes: #3230
1 parent 5af6b79 commit 3a6af67

File tree

13 files changed

+46
-25
lines changed

13 files changed

+46
-25
lines changed

CHANGELOG.asciidoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Notes:
3131
[[release-notes-3.x]]
3232
=== Node.js Agent version 3.x
3333
34+
3435
==== Unreleased
3536
3637
[float]
@@ -45,16 +46,17 @@ Notes:
4546
[float]
4647
===== Bug fixes
4748
49+
* Ensure `metadata.service.agent.activation_method` is only sent for APM
50+
server version 8.7.1 or later. APM server 8.7.0 included a bug where
51+
receiving `activation_method` is harmful. ({issues}3230[#3230])
52+
4853
[float]
4954
===== Chores
5055
5156
5257
[[release-notes-3.43.0]]
5358
==== 3.43.0 2023/03/02
5459
55-
[float]
56-
===== Breaking changes
57-
5860
[float]
5961
===== Features
6062
@@ -72,7 +74,7 @@ Notes:
7274
7375
* Make `Agent.flush()` return a `Promise` if no callback is passed as param.
7476
This means that flush is now `await`able: `await apm.flush()`.
75-
({issues}2857(#2857))
77+
({issues}2857[#2857])
7678
7779
[float]
7880
===== Bug fixes

lib/instrumentation/azure-functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function getAzureFunctionsExtraMetadata () {
252252
// Passing this service.framework.name to Client#setExtraMetadata()
253253
// ensures that it "wins" over a framework name from
254254
// `agent.setFramework()`, because in the client `_extraMetadata`
255-
// wins over `_conf.metadata`.
255+
// wins over `_conf.frameworkName`.
256256
name: 'Azure Functions',
257257
version: process.env.FUNCTIONS_EXTENSION_VERSION
258258
},

lib/lambda.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function getMetadata (agent, cloudAccountId) {
5858
// Passing this service.framework.name to Client#setExtraMetadata()
5959
// ensures that it "wins" over a framework name from
6060
// `agent.setFramework()`, because in the client `_extraMetadata`
61-
// wins over `_conf.metadata`.
61+
// wins over `_conf.frameworkName`.
6262
name: 'AWS Lambda'
6363
},
6464
runtime: {

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"lint:yaml-files": "./dev-utils/lint-yaml-files.sh # requires node >=10",
1616
"coverage": "COVERAGE=true ./test/script/run_tests.sh",
1717
"test": "./test/script/run_tests.sh",
18-
"test:deps": "dependency-check index.js start.js start-next.js 'lib/**/*.js' 'test/**/*.js' '!test/activation-method/fixtures' '!test/instrumentation/modules/next/a-nextjs-app' --no-dev -i async_hooks -i perf_hooks -i node:http -i @azure/functions-core",
18+
"test:deps": "dependency-check index.js start.js start-next.js 'lib/**/*.js' 'test/**/*.js' '!test/activation-method/fixtures' '!test/instrumentation/azure-functions/fixtures' '!test/instrumentation/modules/next/a-nextjs-app' --no-dev -i async_hooks -i perf_hooks -i node:http -i @azure/functions-core",
1919
"test:tav": "tav --quiet && (cd test/instrumentation/modules/next/a-nextjs-app && tav --quiet)",
2020
"test:docs": "./test/script/docker/run_docs.sh",
2121
"test:types": "tsc --project test/types/tsconfig.json && tsc --project test/types/transpile/tsconfig.json && node test/types/transpile/index.js && tsc --project test/types/transpile-default/tsconfig.json && node test/types/transpile-default/index.js # requires node >=12.20",
@@ -95,7 +95,7 @@
9595
"cookie": "^0.5.0",
9696
"core-util-is": "^1.0.2",
9797
"debug": "^4.1.1",
98-
"elastic-apm-http-client": "11.2.0",
98+
"elastic-apm-http-client": "11.3.1",
9999
"end-of-stream": "^1.4.4",
100100
"error-callsites": "^2.0.4",
101101
"error-stack-parser": "^2.0.6",

test/_capturing_transport.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class CapturingTransport {
9898
return true
9999
}
100100

101+
supportsActivationMethodField () {
102+
return true
103+
}
104+
101105
// Inherited from Writable, called in agent.js.
102106
destroy () {}
103107
}

test/_mock_http_client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ module.exports = function (expected, done) {
6969
},
7070
supportsKeepingUnsampledTransaction () {
7171
return true
72+
},
73+
supportsActivationMethodField () {
74+
return true
7275
}
7376
}
7477

test/_mock_http_client_states.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ module.exports = function (expectations = [], done) {
5050
},
5151
supportsKeepingUnsampledTransaction () {
5252
return true
53+
},
54+
supportsActivationMethodField () {
55+
return true
5356
}
5457
}
5558
}

test/activation-method/activation-method.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ tape.test('metadata.system.agent.activation_method fixtures', function (suite) {
107107

108108
const envStr = c.env ? Object.keys(c.env).map(k => `${k}="${c.env[k]}"`).join(' ') : ''
109109
suite.test(`${envStr} node ${(c.nodeOpts || []).join(' ')} ${c.script}`, t => {
110-
const server = new MockAPMServer()
110+
const server = new MockAPMServer({ apmServerVersion: '8.7.1' })
111111
const args = c.nodeOpts || []
112112
args.push(c.script)
113113
server.start(function (serverUrl) {

test/agent.test.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ const agentOpts = {
3434
metricsInterval: '0s',
3535
cloudProvider: 'none',
3636
spanStackTraceMinDuration: 0, // Always have span stacktraces.
37-
logLevel: 'warn'
37+
logLevel: 'warn',
38+
// Ensure the APM client's `GET /` requests do not get in the way of test
39+
// asserts. Also ensure it is new enough to include 'activation_method'.
40+
apmServerVersion: '8.7.1'
3841
}
3942
const agentOptsNoopTransport = Object.assign(
4043
{},
@@ -574,12 +577,7 @@ test('filters', function (t) {
574577
filterAgentOpts = Object.assign(
575578
{},
576579
agentOpts,
577-
{
578-
serverUrl,
579-
// Ensure the APM client's `GET /` requests do not get in the way of
580-
// the test asserts below.
581-
apmServerVersion: '8.0.0'
582-
}
580+
{ serverUrl }
583581
)
584582
t.end()
585583
})

0 commit comments

Comments
 (0)