From 83d360b46eee493546b822ff367a8f9cdd522630 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Tue, 12 Nov 2024 17:04:30 +0000 Subject: [PATCH] Support K8S_ATTACH environment variable for activation (#2482) Adds support for reading K8S_ATTACH to identify activation method --- src/Elastic.Apm/Api/Service.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Elastic.Apm/Api/Service.cs b/src/Elastic.Apm/Api/Service.cs index 058640b7a..4a827d2bd 100644 --- a/src/Elastic.Apm/Api/Service.cs +++ b/src/Elastic.Apm/Api/Service.cs @@ -96,7 +96,9 @@ static bool CheckForLoadedAssembly(string name) // Legacy mechanism: if the profiler is loaded add a `p` suffix to Agent.Version service.Agent.Version += "-p"; // Check if profiler was injected via K8S hook. - if (new EnvironmentVariables(logger).SafeCheckValue("ELASTIC_APM_ACTIVATION_METHOD", "K8S")) + var envvars =new EnvironmentVariables(logger); + if (envvars.SafeCheckValue("ELASTIC_APM_ACTIVATION_METHOD", "K8S") + || envvars.SafeCheckValue("ELASTIC_APM_ACTIVATION_METHOD", "K8S_ATTACH")) activationMethod = Consts.ActivationK8SAttach; else activationMethod = Consts.ActivationMethodProfiler;