Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support 'K8S_ATTACH' value for 'ELASTIC_APM_ACTIVATION_METHOD' #3819

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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