Skip to content

Commit

Permalink
Update how protocol is set
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Dec 20, 2022
1 parent 2a70f7d commit e8c7252
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
20 changes: 14 additions & 6 deletions pkg/instrumentation/podmutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand Down Expand Up @@ -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",
Expand Down
32 changes: 16 additions & 16 deletions pkg/instrumentation/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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{
Expand Down
8 changes: 8 additions & 0 deletions pkg/instrumentation/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
},
},
},
},
Expand Down

0 comments on commit e8c7252

Please sign in to comment.