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..b043e60a6b --- /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: 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] + +# (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/constants/env.go b/pkg/constants/env.go index 01180842a4..d5274ade7a 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/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 436cba28db..c457145737 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", @@ -3369,6 +3625,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", @@ -3440,6 +3712,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", @@ -3511,6 +3799,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", @@ -3558,6 +3862,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", @@ -3605,6 +3925,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", @@ -3652,6 +3988,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", @@ -3699,6 +4051,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", @@ -3762,6 +4130,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", @@ -4025,6 +4409,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", @@ -4096,6 +4496,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", @@ -4167,6 +4583,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", @@ -4214,6 +4646,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", @@ -4261,6 +4709,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", @@ -4308,6 +4772,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", @@ -4355,6 +4835,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", @@ -4418,6 +4914,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", @@ -4894,6 +5406,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 34a383e3e6..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 @@ -235,6 +234,31 @@ 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.EnvPodIP) + if idx == -1 { + container.Env = append([]corev1.EnvVar{{ + Name: constants.EnvPodIP, + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }}, container.Env...) + } + + idx = getIndexOfEnv(container.Env, constants.EnvNodeIP) + if idx == -1 { + container.Env = append([]corev1.EnvVar{{ + Name: constants.EnvNodeIP, + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.hostIP", + }, + }, + }}, container.Env...) + } + for _, env := range otelinst.Spec.Env { idx := getIndexOfEnv(container.Env, env.Name) if idx == -1 { 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..6eacda120d 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: 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 0acbcea3fc..c99268789a 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: status.podIP - name: OTEL_SERVICE_NAME value: my-apache-multi - name: OTEL_EXPORTER_OTLP_ENDPOINT @@ -33,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-apache-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-apache-multicontainer/02-assert.yaml index b6b75f981c..62080ceb74 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: 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 7530bad59a..91ecb8117a 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: status.podIP - name: ASPNETCORE_URLS value: http://+:8080 - name: OTEL_LOG_LEVEL @@ -62,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-dotnet-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-dotnet-multicontainer/02-assert.yaml index 81f08a3753..dfda236729 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: 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 3799c305ae..509d5b9854 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: 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 8a2bfb3cfe..a5dc1fcc92 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: 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 c8ba363d19..cec1654cbe 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: 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 bae190f2d9..f48752ff46 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: status.podIP - name: OTEL_JAVAAGENT_DEBUG value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED @@ -52,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-java-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-java-multicontainer/02-assert.yaml index 6cb2a51d08..03c002d2d8 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: 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 a116899e80..d6c440b27f 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: 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 da1b79cab4..cd8a8a37fe 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: 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 f7cc0b663f..1f06f730a1 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: 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 06534eed2a..8b420b4262 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: status.podIP - name: LD_LIBRARY_PATH value: /opt:/opt/opentelemetry-webserver/agent/sdk_lib/lib - name: OTEL_SERVICE_NAME @@ -42,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-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 diff --git a/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml b/tests/e2e-instrumentation/instrumentation-nginx/01-assert.yaml index eb615846e5..af808fa3e4 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: 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 9e691c3e29..7da5c15637 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: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: NODE_OPTIONS @@ -48,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-nodejs-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-nodejs-multicontainer/02-assert.yaml index 41c1efb269..0738786abd 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: 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 5c8da8b9e1..b228cafc08 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: 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 382b682fbb..492173d1ab 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: status.podIP - name: PYTHONPATH value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python - name: OTEL_TRACES_EXPORTER @@ -52,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 diff --git a/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml b/tests/e2e-instrumentation/instrumentation-python-multicontainer/02-assert.yaml index 49a0db44b1..8e136d7f7c 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: 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 efcb840f91..722cd5c839 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: 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 653929005a..9046a86d64 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: 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 b5358f78d1..390b702220 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: status.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: status.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: status.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: 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 07b8002d38..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 @@ -9,6 +9,14 @@ metadata: spec: containers: - env: + - name: OTEL_NODE_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: OTEL_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP - name: NODE_PATH value: /usr/local/lib/node_modules - name: OTEL_SERVICE_NAME