From 0725566f12daa924fa46b3b89da9de7d697de9eb Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:18:23 -0600 Subject: [PATCH 1/7] Add node and pod ip env vars automatically --- pkg/constants/env.go | 2 ++ pkg/instrumentation/sdk.go | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 12391fde7e..134a118fdd 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -33,7 +33,9 @@ const ( EnvPodName = "OTEL_RESOURCE_ATTRIBUTES_POD_NAME" EnvPodUID = "OTEL_RESOURCE_ATTRIBUTES_POD_UID" + EnvPodIP = "OTEL_POD_IP" EnvNodeName = "OTEL_RESOURCE_ATTRIBUTES_NODE_NAME" + EnvNodeIP = "OTEL_NODE_IP" FlagApacheHttpd = "enable-apache-httpd-instrumentation" FlagDotNet = "enable-dotnet-instrumentation" diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index 34a383e3e6..f35631610a 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -235,6 +235,32 @@ func getContainerIndex(containerName string, pod corev1.Pod) int { func (i *sdkInjector) injectCommonEnvVar(otelinst v1alpha1.Instrumentation, pod corev1.Pod, index int) corev1.Pod { container := &pod.Spec.Containers[index] + + idx := getIndexOfEnv(container.Env, constants.EnvNodeIP) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: constants.EnvNodeIP, + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }) + } + + idx = getIndexOfEnv(container.Env, constants.EnvPodIP) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: constants.EnvPodIP, + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + APIVersion: "v1", + FieldPath: "status.podIP", + }, + }, + }) + } + for _, env := range otelinst.Spec.Env { idx := getIndexOfEnv(container.Env, env.Name) if idx == -1 { From 57c7ebdebe96f75ff66ea2056a931f0c9f3f26f8 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:06:21 -0600 Subject: [PATCH 2/7] Fix tests --- .chloggen/include-node-ip-in-env-vars.yaml | 16 + README.md | 2 + pkg/instrumentation/podmutator_test.go | 528 ++++++++++++++++++ pkg/instrumentation/sdk.go | 22 +- pkg/instrumentation/sdk_test.go | 144 +++++ .../01-assert.yaml | 8 + .../01-assert.yaml | 8 + .../02-assert.yaml | 8 + .../01-assert.yaml | 8 + .../02-assert.yaml | 8 + .../01-assert.yaml | 8 + .../instrumentation-dotnet/01-assert.yaml | 8 + .../instrumentation-go/02-assert.yaml | 8 + .../01-assert.yaml | 8 + .../02-assert.yaml | 8 + .../03-assert.yaml | 8 + .../instrumentation-java/01-assert.yaml | 8 + .../01-assert.yaml | 8 + .../01-assert.yaml | 8 + .../instrumentation-nginx/01-assert.yaml | 8 + .../01-assert.yaml | 8 + .../02-assert.yaml | 8 + .../instrumentation-nodejs/01-assert.yaml | 8 + .../01-assert.yaml | 8 + .../02-assert.yaml | 8 + .../instrumentation-python/01-assert.yaml | 8 + .../instrumentation-sdk/01-assert.yaml | 8 + 27 files changed, 876 insertions(+), 12 deletions(-) create mode 100755 .chloggen/include-node-ip-in-env-vars.yaml diff --git a/.chloggen/include-node-ip-in-env-vars.yaml b/.chloggen/include-node-ip-in-env-vars.yaml new file mode 100755 index 0000000000..0bcb85e27d --- /dev/null +++ b/.chloggen/include-node-ip-in-env-vars.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: instrumentation + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add node and pod ips as env vars automatically + +# One or more tracking issues related to the change +issues: [2769] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/README.md b/README.md index 1f80f99d2b..3eda2cd8b7 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,8 @@ The value for `sampler.type` is added to the `OTEL_TRACES_SAMPLER` environment v Valid values for `sampler.type` are defined by the [OpenTelemetry Specification for OTEL_TRACES_SAMPLER](https://opentelemetry.io/docs/concepts/sdk-configuration/general-sdk-configuration/#otel_traces_sampler). The value for `sampler.argument` is added to the `OTEL_TRACES_SAMPLER_ARG` environment variable. Valid values for `sampler.argument` will depend on the chosen sampler. See the [OpenTelemetry Specification for OTEL_TRACES_SAMPLER_ARG](https://opentelemetry.io/docs/concepts/sdk-configuration/general-sdk-configuration/#otel_traces_sampler_arg) for more details. +The instrumentation will automatically inject `OTEL_NODE_IP` and `OTEL_POD_IP` environment variables should you need to reference either value in an endpoint. + The above CR can be queried by `kubectl get otelinst`. Then add an annotation to a pod to enable injection. The annotation can be added to a namespace, so that all pods within diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 7343db7525..17f8b6a71a 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -154,6 +154,22 @@ func TestMutatePod(t *testing.T) { { Name: "app", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_JAVAAGENT_DEBUG", Value: "true", @@ -342,6 +358,22 @@ func TestMutatePod(t *testing.T) { { Name: "app1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_JAVAAGENT_DEBUG", Value: "true", @@ -417,6 +449,22 @@ func TestMutatePod(t *testing.T) { { Name: "app2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_JAVAAGENT_DEBUG", Value: "true", @@ -688,6 +736,22 @@ func TestMutatePod(t *testing.T) { { Name: "app", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_NODEJS_DEBUG", Value: "true", @@ -860,6 +924,22 @@ func TestMutatePod(t *testing.T) { { Name: "app1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_NODEJS_DEBUG", Value: "true", @@ -927,6 +1007,22 @@ func TestMutatePod(t *testing.T) { { Name: "app2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_NODEJS_DEBUG", Value: "true", @@ -1187,6 +1283,22 @@ func TestMutatePod(t *testing.T) { { Name: "app", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -1376,6 +1488,22 @@ func TestMutatePod(t *testing.T) { { Name: "app1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -1455,6 +1583,22 @@ func TestMutatePod(t *testing.T) { { Name: "app2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -1719,6 +1863,22 @@ func TestMutatePod(t *testing.T) { { Name: "app", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -1899,6 +2059,22 @@ func TestMutatePod(t *testing.T) { { Name: "app", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -2088,6 +2264,22 @@ func TestMutatePod(t *testing.T) { { Name: "app1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -2175,6 +2367,22 @@ func TestMutatePod(t *testing.T) { { Name: "app2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -2434,6 +2642,22 @@ func TestMutatePod(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_GO_AUTO_TARGET_EXE", Value: "/app", @@ -2710,6 +2934,22 @@ func TestMutatePod(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_SERVICE_NAME", Value: "app", @@ -2943,6 +3183,22 @@ func TestMutatePod(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "LD_LIBRARY_PATH", Value: "/opt/opentelemetry-webserver/agent/sdk_lib/lib", @@ -3381,6 +3637,22 @@ func TestMutatePod(t *testing.T) { { Name: "dotnet1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3452,6 +3724,22 @@ func TestMutatePod(t *testing.T) { { Name: "dotnet2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3523,6 +3811,22 @@ func TestMutatePod(t *testing.T) { { Name: "java1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3570,6 +3874,22 @@ func TestMutatePod(t *testing.T) { { Name: "java2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3617,6 +3937,22 @@ func TestMutatePod(t *testing.T) { { Name: "nodejs1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3664,6 +4000,22 @@ func TestMutatePod(t *testing.T) { { Name: "nodejs2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3711,6 +4063,22 @@ func TestMutatePod(t *testing.T) { { Name: "python1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -3774,6 +4142,22 @@ func TestMutatePod(t *testing.T) { { Name: "python2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4037,6 +4421,22 @@ func TestMutatePod(t *testing.T) { { Name: "dotnet1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4108,6 +4508,22 @@ func TestMutatePod(t *testing.T) { { Name: "dotnet2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4179,6 +4595,22 @@ func TestMutatePod(t *testing.T) { { Name: "java1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4226,6 +4658,22 @@ func TestMutatePod(t *testing.T) { { Name: "java2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4273,6 +4721,22 @@ func TestMutatePod(t *testing.T) { { Name: "nodejs1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4320,6 +4784,22 @@ func TestMutatePod(t *testing.T) { { Name: "nodejs2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4367,6 +4847,22 @@ func TestMutatePod(t *testing.T) { { Name: "python1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4430,6 +4926,22 @@ func TestMutatePod(t *testing.T) { { Name: "python2", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", @@ -4906,6 +5418,22 @@ func TestMutatePod(t *testing.T) { { Name: "dotnet1", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_LOG_LEVEL", Value: "debug", diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index f35631610a..d88b36f9ca 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -57,7 +57,6 @@ func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations if len(pod.Spec.Containers) < 1 { return pod } - if insts.Java.Instrumentation != nil { otelinst := *insts.Java.Instrumentation var err error @@ -236,29 +235,28 @@ func getContainerIndex(containerName string, pod corev1.Pod) int { func (i *sdkInjector) injectCommonEnvVar(otelinst v1alpha1.Instrumentation, pod corev1.Pod, index int) corev1.Pod { container := &pod.Spec.Containers[index] - idx := getIndexOfEnv(container.Env, constants.EnvNodeIP) + idx := getIndexOfEnv(container.Env, constants.EnvPodIP) if idx == -1 { - container.Env = append(container.Env, corev1.EnvVar{ - Name: constants.EnvNodeIP, + container.Env = append([]corev1.EnvVar{{ + Name: constants.EnvPodIP, ValueFrom: &corev1.EnvVarSource{ FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "status.hostIP", + FieldPath: "status.podIP", }, }, - }) + }}, container.Env...) } - idx = getIndexOfEnv(container.Env, constants.EnvPodIP) + idx = getIndexOfEnv(container.Env, constants.EnvNodeIP) if idx == -1 { - container.Env = append(container.Env, corev1.EnvVar{ - Name: constants.EnvPodIP, + container.Env = append([]corev1.EnvVar{{ + Name: constants.EnvNodeIP, ValueFrom: &corev1.EnvVarSource{ FieldRef: &corev1.ObjectFieldSelector{ - APIVersion: "v1", - FieldPath: "status.podIP", + FieldPath: "status.hostIP", }, }, - }) + }}, container.Env...) } for _, env := range otelinst.Spec.Env { diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index a1024be110..36c2d564ca 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -555,6 +555,22 @@ func TestInjectJava(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "JAVA_TOOL_OPTIONS", Value: javaJVMArgument, @@ -660,6 +676,22 @@ func TestInjectNodeJS(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "NODE_OPTIONS", Value: nodeRequireArgument, @@ -764,6 +796,22 @@ func TestInjectPython(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "PYTHONPATH", Value: fmt.Sprintf("%s:%s", pythonPathPrefix, pythonPathSuffix), @@ -883,6 +931,22 @@ func TestInjectDotNet(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: envDotNetCoreClrEnableProfiling, Value: dotNetCoreClrEnableProfilingEnabled, @@ -1072,6 +1136,22 @@ func TestInjectGo(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_GO_AUTO_TARGET_EXE", Value: "foo", @@ -1173,6 +1253,22 @@ func TestInjectGo(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_GO_AUTO_TARGET_EXE", Value: "foo", @@ -1342,6 +1438,22 @@ func TestInjectApacheHttpd(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_SERVICE_NAME", Value: "app", @@ -1510,6 +1622,22 @@ func TestInjectNginx(t *testing.T) { }, }, Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "LD_LIBRARY_PATH", Value: "/opt/opentelemetry-webserver/agent/sdk_lib/lib", @@ -1587,6 +1715,22 @@ func TestInjectSdkOnly(t *testing.T) { Name: "app", Image: "app:latest", Env: []corev1.EnvVar{ + { + Name: "OTEL_NODE_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }, + { + Name: "OTEL_POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, { Name: "OTEL_SERVICE_NAME", Value: "app", diff --git a/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml index e390fe7840..ff54fbfeba 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_SERVICE_NAME value: my-apache - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml index 0acbcea3fc..9bea5dfc2f 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml @@ -10,6 +10,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_SERVICE_NAME value: my-apache-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml index b6b75f981c..ec1df5c6a2 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml @@ -21,6 +21,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_SERVICE_NAME value: my-apache-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml index 7530bad59a..bce40abc49 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -10,6 +10,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: OTEL_LOG_LEVEL diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml index 81f08a3753..e479bd0e3a 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml @@ -21,6 +21,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: OTEL_LOG_LEVEL diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml index 3799c305ae..f9c64e8a35 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: CORECLR_ENABLE_PROFILING diff --git a/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml index 8a2bfb3cfe..8d392c4d63 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: CORECLR_ENABLE_PROFILING diff --git a/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml index c8ba363d19..0588522fd3 100644 --- a/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml @@ -14,6 +14,14 @@ spec: - --config=env:OTEL_CONFIG name: otc-container - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_GO_AUTO_TARGET_EXE value: /usr/src/app/productcatalogservice - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml index bae190f2d9..cd0a72ddbd 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml @@ -10,6 +10,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml index 6cb2a51d08..113e873981 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml @@ -21,6 +21,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml index a116899e80..76745492b5 100644 --- a/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml index da1b79cab4..db4c74052e 100644 --- a/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml index f7cc0b663f..b29973a97e 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml index 06534eed2a..0a3d4f1f97 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml @@ -10,6 +10,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml index eb615846e5..4b0fb9a29a 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml index 9e691c3e29..584f1fd26c 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml @@ -10,6 +10,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml index 41c1efb269..a5493dc333 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml @@ -21,6 +21,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS diff --git a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml index 5c8da8b9e1..b43462249f 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_NODEJS_DEBUG diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml index 382b682fbb..40dd4dfc10 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml @@ -10,6 +10,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: PYTHONPATH value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml index 49a0db44b1..e93bcd28c8 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml @@ -21,6 +21,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: PYTHONPATH value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml index efcb840f91..58e933a6e2 100644 --- a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_LOG_LEVEL value: debug - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml index 653929005a..0caa7bd3f8 100644 --- a/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED value: "true" - name: OTEL_SERVICE_NAME From 375b25995e7bae0f4020ac74ce93e25ec8022fc0 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:21:20 -0600 Subject: [PATCH 3/7] Fix tests --- .../01-assert.yaml | 32 +++++++++++++++++++ .../01-assert.yaml | 8 +++++ 2 files changed, 40 insertions(+) diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml index b5358f78d1..e1d464f4bd 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -17,6 +17,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: ASPNETCORE_URLS value: http://+:8083 - name: OTEL_SERVICE_NAME @@ -61,6 +69,14 @@ spec: - mountPath: /otel-auto-instrumentation-dotnet name: opentelemetry-auto-instrumentation-dotnet - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_SERVICE_NAME value: javaapp - name: JAVA_TOOL_OPTIONS @@ -91,6 +107,14 @@ spec: - mountPath: /otel-auto-instrumentation-java name: opentelemetry-auto-instrumentation-java - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_SERVICE_NAME @@ -128,6 +152,14 @@ spec: - -p - "8087" env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: OTEL_SERVICE_NAME value: pythonapp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml index 07b8002d38..077c38077e 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: spec.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_SERVICE_NAME From 8b2ef8c6cf88f898325476cf9fc22cf37b4b8642 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:27:02 -0600 Subject: [PATCH 4/7] Fix tests --- .../instrumentation-apache-httpd/01-assert.yaml | 2 +- .../instrumentation-apache-multicontainer/01-assert.yaml | 2 +- .../instrumentation-apache-multicontainer/02-assert.yaml | 2 +- .../instrumentation-dotnet-multicontainer/01-assert.yaml | 2 +- .../instrumentation-dotnet-multicontainer/02-assert.yaml | 2 +- .../instrumentation-dotnet-musl/01-assert.yaml | 2 +- .../instrumentation-dotnet/01-assert.yaml | 2 +- .../e2e-instrumentation/instrumentation-go/02-assert.yaml | 2 +- .../instrumentation-java-multicontainer/01-assert.yaml | 2 +- .../instrumentation-java-multicontainer/02-assert.yaml | 2 +- .../instrumentation-java-other-ns/03-assert.yaml | 2 +- .../instrumentation-java/01-assert.yaml | 2 +- .../instrumentation-nginx-contnr-secctx/01-assert.yaml | 2 +- .../instrumentation-nginx-multicontainer/01-assert.yaml | 2 +- .../instrumentation-nginx/01-assert.yaml | 2 +- .../instrumentation-nodejs-multicontainer/01-assert.yaml | 2 +- .../instrumentation-nodejs-multicontainer/02-assert.yaml | 2 +- .../instrumentation-nodejs/01-assert.yaml | 2 +- .../instrumentation-python-multicontainer/01-assert.yaml | 2 +- .../instrumentation-python-multicontainer/02-assert.yaml | 2 +- .../instrumentation-python/01-assert.yaml | 2 +- .../instrumentation-sdk/01-assert.yaml | 2 +- .../instrumentation-multi-multicontainer/01-assert.yaml | 8 ++++---- .../01-assert.yaml | 2 +- 24 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml index ff54fbfeba..6eacda120d 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-httpd/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: my-apache - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml index 9bea5dfc2f..5ec62d4916 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml @@ -17,7 +17,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: my-apache-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml index ec1df5c6a2..62080ceb74 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml @@ -28,7 +28,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: my-apache-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml index bce40abc49..a0efefaf76 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -17,7 +17,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: OTEL_LOG_LEVEL diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml index e479bd0e3a..dfda236729 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml @@ -28,7 +28,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: OTEL_LOG_LEVEL diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml index f9c64e8a35..509d5b9854 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-musl/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: CORECLR_ENABLE_PROFILING diff --git a/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml index 8d392c4d63..a5dc1fcc92 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: CORECLR_ENABLE_PROFILING diff --git a/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml index 0588522fd3..cec1654cbe 100644 --- a/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-go/02-assert.yaml @@ -21,7 +21,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_GO_AUTO_TARGET_EXE value: /usr/src/app/productcatalogservice - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml index cd0a72ddbd..cea4bfb4b3 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml @@ -17,7 +17,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml index 113e873981..03c002d2d8 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml @@ -28,7 +28,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml index 76745492b5..d6c440b27f 100644 --- a/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-other-ns/03-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml index db4c74052e..cd8a8a37fe 100644 --- a/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml index b29973a97e..1f06f730a1 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx-contnr-secctx/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml index 0a3d4f1f97..c3798ee38f 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml @@ -17,7 +17,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml index 4b0fb9a29a..af808fa3e4 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml index 584f1fd26c..e6a2978160 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml @@ -17,7 +17,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml index a5493dc333..0738786abd 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml @@ -28,7 +28,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS diff --git a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml index b43462249f..b228cafc08 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_NODEJS_DEBUG diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml index 40dd4dfc10..7f21d8f588 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml @@ -17,7 +17,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: PYTHONPATH value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml index e93bcd28c8..8e136d7f7c 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml @@ -28,7 +28,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: PYTHONPATH value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml index 58e933a6e2..722cd5c839 100644 --- a/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_LOG_LEVEL value: debug - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml index 0caa7bd3f8..9046a86d64 100644 --- a/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-sdk/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED value: "true" - name: OTEL_SERVICE_NAME diff --git a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml index e1d464f4bd..390b702220 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/01-assert.yaml @@ -24,7 +24,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: ASPNETCORE_URLS value: http://+:8083 - name: OTEL_SERVICE_NAME @@ -76,7 +76,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: javaapp - name: JAVA_TOOL_OPTIONS @@ -114,7 +114,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_SERVICE_NAME @@ -159,7 +159,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: pythonapp - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml index 077c38077e..d9d1801260 100644 --- a/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml +++ b/tests/e2e-multi-instrumentation/instrumentation-single-instr-first-container/01-assert.yaml @@ -16,7 +16,7 @@ spec: - name: OTEL_POD_IP valueFrom: fieldRef: - fieldPath: spec.podIP + fieldPath: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_SERVICE_NAME From 2839012c4cf556f2476f41be2b67d33f38bb501e Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:48:50 -0600 Subject: [PATCH 5/7] Fix tests --- .../instrumentation-apache-multicontainer/01-assert.yaml | 8 ++++++++ .../instrumentation-dotnet-multicontainer/01-assert.yaml | 8 ++++++++ .../instrumentation-java-multicontainer/01-assert.yaml | 8 ++++++++ .../instrumentation-nginx-multicontainer/01-assert.yaml | 8 ++++++++ .../instrumentation-nodejs-multicontainer/01-assert.yaml | 8 ++++++++ .../instrumentation-python-multicontainer/01-assert.yaml | 8 ++++++++ 6 files changed, 48 insertions(+) diff --git a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml index 5ec62d4916..c99268789a 100644 --- a/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/01-assert.yaml @@ -41,6 +41,14 @@ spec: - name: OTEL_RESOURCE_ATTRIBUTES name: myapp - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: my-apache-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml index a0efefaf76..91ecb8117a 100644 --- a/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/01-assert.yaml @@ -70,6 +70,14 @@ spec: - mountPath: /otel-auto-instrumentation-dotnet name: opentelemetry-auto-instrumentation-dotnet - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: OTEL_LOG_LEVEL value: debug - name: CORECLR_ENABLE_PROFILING diff --git a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml index cea4bfb4b3..f48752ff46 100644 --- a/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-java-multicontainer/01-assert.yaml @@ -60,6 +60,14 @@ spec: - mountPath: /otel-auto-instrumentation-java name: opentelemetry-auto-instrumentation-java - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED diff --git a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml index c3798ee38f..8b420b4262 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/01-assert.yaml @@ -50,6 +50,14 @@ spec: - mountPath: /etc/nginx name: otel-nginx-conf-dir - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: OTEL_SERVICE_NAME value: my-nginx-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT diff --git a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml index e6a2978160..7da5c15637 100644 --- a/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/01-assert.yaml @@ -56,6 +56,14 @@ spec: - mountPath: /otel-auto-instrumentation-nodejs name: opentelemetry-auto-instrumentation-nodejs - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: NODE_OPTIONS value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' - name: OTEL_TRACES_EXPORTER diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml index 7f21d8f588..492173d1ab 100644 --- a/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-python-multicontainer/01-assert.yaml @@ -60,6 +60,14 @@ spec: - mountPath: /otel-auto-instrumentation-python name: opentelemetry-auto-instrumentation-python - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: PYTHONPATH value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python - name: OTEL_TRACES_EXPORTER From a47c8e779f33fc56fd6da67ab72a7d53e1455e72 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:26:09 -0600 Subject: [PATCH 6/7] Fix tests --- .../instrumentation-nginx-multicontainer/02-assert.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/02-assert.yaml index 81a43e7aa7..9b0543a336 100644 --- a/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/02-assert.yaml +++ b/tests/e2e-instrumentation/instrumentation-nginx-multicontainer/02-assert.yaml @@ -21,6 +21,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME From d6d2245fe9185ba9307afd94b43c2de5c40a2a31 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:36:15 -0600 Subject: [PATCH 7/7] Update changelog --- .chloggen/include-node-ip-in-env-vars.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/include-node-ip-in-env-vars.yaml b/.chloggen/include-node-ip-in-env-vars.yaml index 0bcb85e27d..b043e60a6b 100755 --- a/.chloggen/include-node-ip-in-env-vars.yaml +++ b/.chloggen/include-node-ip-in-env-vars.yaml @@ -5,7 +5,7 @@ change_type: enhancement component: instrumentation # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add node and pod ips as env vars automatically +note: Instrumentation now automatically add node and pod ips as env vars `OTEL_NODE_IP` and `OTEL_POD_IP` to instrumented containers. # One or more tracking issues related to the change issues: [2769]