From 23834c807523c51b118845fdab26b8a6c4e6bdf2 Mon Sep 17 00:00:00 2001 From: Elvis Cai Date: Tue, 15 Feb 2022 17:49:23 +1100 Subject: [PATCH] add SPLUNK_ env prefix support --- apis/v1alpha1/instrumentation_webhook.go | 5 +-- pkg/instrumentation/podmutator_test.go | 32 +++++++++++++++++++ .../00-install-instrumentation.yaml | 4 +++ tests/e2e/instrumentation-java/01-assert.yaml | 4 +++ .../00-install-instrumentation.yaml | 2 ++ .../e2e/instrumentation-nodejs/01-assert.yaml | 2 ++ .../00-install-instrumentation.yaml | 4 ++- .../e2e/instrumentation-python/01-assert.yaml | 2 ++ 8 files changed, 52 insertions(+), 3 deletions(-) diff --git a/apis/v1alpha1/instrumentation_webhook.go b/apis/v1alpha1/instrumentation_webhook.go index 1fef3ee4d1..f2793a8640 100644 --- a/apis/v1alpha1/instrumentation_webhook.go +++ b/apis/v1alpha1/instrumentation_webhook.go @@ -31,6 +31,7 @@ const ( AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image" AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image" envPrefix = "OTEL_" + envSplunkPrefix = "SPLUNK_" ) // log is for logging in this package. @@ -130,8 +131,8 @@ func (in *Instrumentation) validate() error { func (in *Instrumentation) validateEnv(envs []corev1.EnvVar) error { for _, env := range envs { - if !strings.HasPrefix(env.Name, envPrefix) { - return fmt.Errorf("env name should start with \"OTEL_\": %s", env.Name) + if !strings.HasPrefix(env.Name, envPrefix) && !strings.HasPrefix(env.Name, envSplunkPrefix) { + return fmt.Errorf("env name should start with \"OTEL_\" or \"SPLUNK_\": %s", env.Name) } } return nil diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index 15766b7a44..00aa549c1b 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -63,6 +63,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_INSTRUMENTATION_JDBC_ENABLED", Value: "false", }, + { + Name: "SPLUNK_PROFILER_ENABLED", + Value: "false", + }, }, }, Env: []corev1.EnvVar{ @@ -86,6 +90,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_TRACES_SAMPLER_ARG", Value: "0.85", }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, }, Exporter: v1alpha1.Exporter{ Endpoint: "http://collector:12345", @@ -143,6 +151,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_INSTRUMENTATION_JDBC_ENABLED", Value: "false", }, + { + Name: "SPLUNK_PROFILER_ENABLED", + Value: "false", + }, { Name: "JAVA_TOOL_OPTIONS", Value: javaJVMArgument, @@ -167,6 +179,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_TRACES_SAMPLER_ARG", Value: "0.85", }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, { Name: "OTEL_SERVICE_NAME", Value: "app", @@ -246,6 +262,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_TRACES_SAMPLER_ARG", Value: "0.85", }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, }, Exporter: v1alpha1.Exporter{ Endpoint: "http://collector:12345", @@ -324,6 +344,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_TRACES_SAMPLER_ARG", Value: "0.85", }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, { Name: "OTEL_SERVICE_NAME", Value: "app", @@ -406,6 +430,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_TRACES_SAMPLER_ARG", Value: "0.85", }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, }, }, }, @@ -481,6 +509,10 @@ func TestMutatePod(t *testing.T) { Name: "OTEL_TRACES_SAMPLER_ARG", Value: "0.85", }, + { + Name: "SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", + Value: "true", + }, { Name: "OTEL_SERVICE_NAME", Value: "app", diff --git a/tests/e2e/instrumentation-java/00-install-instrumentation.yaml b/tests/e2e/instrumentation-java/00-install-instrumentation.yaml index 793f5a87f7..f77a3f835f 100644 --- a/tests/e2e/instrumentation-java/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-java/00-install-instrumentation.yaml @@ -14,6 +14,8 @@ spec: value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" exporter: endpoint: http://localhost:4317 propagators: @@ -28,3 +30,5 @@ spec: value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" diff --git a/tests/e2e/instrumentation-java/01-assert.yaml b/tests/e2e/instrumentation-java/01-assert.yaml index cdc33dcc36..526b21b881 100644 --- a/tests/e2e/instrumentation-java/01-assert.yaml +++ b/tests/e2e/instrumentation-java/01-assert.yaml @@ -14,6 +14,8 @@ spec: value: "true" - name: OTEL_INSTRUMENTATION_JDBC_ENABLED value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" - name: JAVA_TOOL_OPTIONS value: " -javaagent:/otel-auto-instrumentation/javaagent.jar" - name: OTEL_TRACES_EXPORTER @@ -26,6 +28,8 @@ spec: value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" - name: OTEL_SERVICE_NAME value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME diff --git a/tests/e2e/instrumentation-nodejs/00-install-instrumentation.yaml b/tests/e2e/instrumentation-nodejs/00-install-instrumentation.yaml index 40459f483a..35154afb2b 100644 --- a/tests/e2e/instrumentation-nodejs/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-nodejs/00-install-instrumentation.yaml @@ -14,6 +14,8 @@ spec: value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" exporter: endpoint: http://localhost:4317 propagators: diff --git a/tests/e2e/instrumentation-nodejs/01-assert.yaml b/tests/e2e/instrumentation-nodejs/01-assert.yaml index d327e85962..37164a387c 100644 --- a/tests/e2e/instrumentation-nodejs/01-assert.yaml +++ b/tests/e2e/instrumentation-nodejs/01-assert.yaml @@ -24,6 +24,8 @@ spec: value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" - name: OTEL_SERVICE_NAME value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME diff --git a/tests/e2e/instrumentation-python/00-install-instrumentation.yaml b/tests/e2e/instrumentation-python/00-install-instrumentation.yaml index fa1fff2353..ab4bd669c9 100644 --- a/tests/e2e/instrumentation-python/00-install-instrumentation.yaml +++ b/tests/e2e/instrumentation-python/00-install-instrumentation.yaml @@ -10,6 +10,8 @@ spec: value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" exporter: endpoint: http://localhost:4317 propagators: @@ -25,4 +27,4 @@ spec: - name: OTEL_TRACES_EXPORTER value: otlp_proto_http - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: http://localhost:4317 \ No newline at end of file + value: http://localhost:4317 diff --git a/tests/e2e/instrumentation-python/01-assert.yaml b/tests/e2e/instrumentation-python/01-assert.yaml index 105cfd30cd..a34d32d9a5 100644 --- a/tests/e2e/instrumentation-python/01-assert.yaml +++ b/tests/e2e/instrumentation-python/01-assert.yaml @@ -24,6 +24,8 @@ spec: value: parentbased_traceidratio - name: OTEL_TRACES_SAMPLER_ARG value: "0.85" + - name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED + value: "true" - name: OTEL_SERVICE_NAME value: my-deployment-with-sidecar - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME