From e8c7252068bb073a8231d6b36d78a17b0180e22f Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 20 Dec 2022 12:03:25 -0700 Subject: [PATCH] Update how protocol is set --- pkg/instrumentation/podmutator_test.go | 20 +++++++++++----- pkg/instrumentation/python.go | 32 +++++++++++++------------- pkg/instrumentation/python_test.go | 8 +++++++ 3 files changed, 38 insertions(+), 22 deletions(-) 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", + }, }, }, },