diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 352f208d63..64a6e1fb0b 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -406,15 +406,15 @@ func TestMutatePod(t *testing.T) { }, { Name: "OTEL_TRACES_EXPORTER", - Value: "otlp_proto_http", + Value: "otlp", }, { Name: "OTEL_METRICS_EXPORTER", - Value: "none", + Value: "otlp", }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", - Value: "http://localhost:4317", + Value: "http://localhost:4318", }, }, }, @@ -491,20 +491,28 @@ func TestMutatePod(t *testing.T) { }, { Name: "OTEL_TRACES_EXPORTER", - Value: "otlp_proto_http", + Value: "otlp", }, { Name: "OTEL_METRICS_EXPORTER", - Value: "none", + Value: "otlp", }, { Name: "OTEL_EXPORTER_OTLP_ENDPOINT", - Value: "http://localhost:4317", + Value: "http://localhost:4318", }, { Name: "PYTHONPATH", Value: fmt.Sprintf("%s:%s", pythonPathPrefix, pythonPathSuffix), }, + { + Name: "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL", + Value: "http/protobuf", + }, + { + Name: "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL", + Value: "http/protobuf", + }, { Name: "OTEL_EXPORTER_OTLP_TIMEOUT", Value: "20", diff --git a/pkg/instrumentation/python.go b/pkg/instrumentation/python.go index 97556d1510..b7eaebc681 100644 --- a/pkg/instrumentation/python.go +++ b/pkg/instrumentation/python.go @@ -66,15 +66,15 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor Name: envOtelTracesExporter, Value: "otlp", }) + } - // Set OTEL_EXPORTER_OTLP_TRACES_PROTOCOL to http/protobuf if not set by user because it is what our autoinstrumentation supports. - idx = getIndexOfEnv(container.Env, envOtelExporterOTLPTracesProtocol) - if idx == -1 { - container.Env = append(container.Env, corev1.EnvVar{ - Name: envOtelExporterOTLPTracesProtocol, - Value: "http/protobuf", - }) - } + // Set OTEL_EXPORTER_OTLP_TRACES_PROTOCOL to http/protobuf if not set by user because it is what our autoinstrumentation supports. + idx = getIndexOfEnv(container.Env, envOtelExporterOTLPTracesProtocol) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envOtelExporterOTLPTracesProtocol, + Value: "http/protobuf", + }) } // Set OTEL_METRICS_EXPORTER to HTTP exporter if not set by user because it is what our autoinstrumentation supports. @@ -84,15 +84,15 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int) (cor Name: envOtelMetricsExporter, Value: "otlp", }) + } - // Set OTEL_EXPORTER_OTLP_METRICS_PROTOCOL to http/protobuf if not set by user because it is what our autoinstrumentation supports. - idx = getIndexOfEnv(container.Env, envOtelExporterOTLPMetricsProtocol) - if idx == -1 { - container.Env = append(container.Env, corev1.EnvVar{ - Name: envOtelExporterOTLPMetricsProtocol, - Value: "http/protobuf", - }) - } + // Set OTEL_EXPORTER_OTLP_METRICS_PROTOCOL to http/protobuf if not set by user because it is what our autoinstrumentation supports. + idx = getIndexOfEnv(container.Env, envOtelExporterOTLPMetricsProtocol) + if idx == -1 { + container.Env = append(container.Env, corev1.EnvVar{ + Name: envOtelExporterOTLPMetricsProtocol, + Value: "http/protobuf", + }) } container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ diff --git a/pkg/instrumentation/python_test.go b/pkg/instrumentation/python_test.go index b4353e5506..716f21fb30 100644 --- a/pkg/instrumentation/python_test.go +++ b/pkg/instrumentation/python_test.go @@ -228,6 +228,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "PYTHONPATH", Value: fmt.Sprintf("%s:%s", pythonPathPrefix, pythonPathSuffix), }, + { + Name: "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL", + Value: "http/protobuf", + }, { Name: "OTEL_METRICS_EXPORTER", Value: "otlp", @@ -306,6 +310,10 @@ func TestInjectPythonSDK(t *testing.T) { Name: "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL", Value: "http/protobuf", }, + { + Name: "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL", + Value: "http/protobuf", + }, }, }, }, diff --git a/tests/e2e/instrumentation-python/01-assert.yaml b/tests/e2e/instrumentation-python/01-assert.yaml index a6dcc4301f..4b7c122ae0 100644 --- a/tests/e2e/instrumentation-python/01-assert.yaml +++ b/tests/e2e/instrumentation-python/01-assert.yaml @@ -14,16 +14,16 @@ spec: value: "debug" - name: OTEL_TRACES_EXPORTER value: otlp + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://localhost:4318 + - name: PYTHONPATH + value: "/otel-auto-instrumentation/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation" - name: OTEL_EXPORTER_OTLP_TRACES_PROTOCOL value: http/protobuf - name: OTEL_METRICS_EXPORTER value: otlp - name: OTEL_EXPORTER_OTLP_METRICS_PROTOCOL value: http/protobuf - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: http://localhost:4318 - - name: PYTHONPATH - value: "/otel-auto-instrumentation/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation" - name: OTEL_EXPORTER_OTLP_TIMEOUT value: "20" - name: OTEL_TRACES_SAMPLER