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 f7a9077
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 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
8 changes: 4 additions & 4 deletions tests/e2e/instrumentation-python/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f7a9077

Please sign in to comment.