Skip to content

Commit

Permalink
chore: support 'K8S_ATTACH' value for 'ELASTIC_APM_ACTIVATION_METHOD' (
Browse files Browse the repository at this point in the history
…#3819)

This is a the new favoured value for the envvar to indicate the apm-k8s-attacher
is being used.
This should be backported.

Refs: elastic/apm-k8s-attacher#91
  • Loading branch information
trentm authored Jan 11, 2024
1 parent a5ea516 commit 7c0ba9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ See the <<upgrade-to-v4>> guide.
[float]
===== Chores
* Support `ELASTIC_APM_ACTIVATION_METHOD=K8S_ATTACH` (in addition to the
current `K8S` value) to indicate the agent is being started by
apm-k8s-attacher. Newer releases of apm-k8s-attacher will be using this
value (to have a common value used between APM agents).
[[release-notes-4.3.0]]
==== 4.3.0 - 2023/12/05
Expand Down
11 changes: 7 additions & 4 deletions lib/activation-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const CONTAINS_R_ELASTIC_APM_NODE_START =
* import 'elastic-apm-node/start.js'
* import apm from 'elastic-apm-node'; apm.start()
* - "aws-lambda-layer": `NODE_OPTIONS` using Agent installed at /opt/nodejs/node_modules/elastic-apm-node
* - "k8s-attach": `NODE_OPTIONS` using Agent, and `ELASTIC_APM_ACTIVATION_METHOD=K8S` in env
* - "k8s-attach": `NODE_OPTIONS` using Agent, and `ELASTIC_APM_ACTIVATION_METHOD=K8S_ATTACH` (or `K8S` for bwcompat to earlier apm-k8s-attacher versions) in env
* - "env-attach": Fallback for any other usage of NODE_OPTIONS='-r elastic-apm-node/start'
* - "preload": For usage of `node -r elastic-apm-node/start` without `NODE_OPTIONS`.
*/
Expand Down Expand Up @@ -82,9 +82,12 @@ function agentActivationMethodFromStartStack(startStack, log) {
// This path is defined by https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
// and created by "dev-utils/make-distribution.sh".
return 'aws-lambda-layer';
} else if (process.env.ELASTIC_APM_ACTIVATION_METHOD === 'K8S') {
// This envvar will be set in versions of apm-k8s-attacher after v0.1.0.
// https://github.com/elastic/apm-k8s-attacher/blob/4faff6299dc689491d628c26503568b09f078cfa/charts/apm-attacher/values.yaml#L33-L38
} else if (
process.env.ELASTIC_APM_ACTIVATION_METHOD === 'K8S_ATTACH' ||
process.env.ELASTIC_APM_ACTIVATION_METHOD === 'K8S'
) {
// apm-k8s-attacher v0.1.0 started setting value to K8S.
// v0.4.0 will start using 'K8S_ATTACH'.
return 'k8s-attach';
} else if (
process.env.NODE_OPTIONS &&
Expand Down

0 comments on commit 7c0ba9d

Please sign in to comment.