Skip to content

Commit

Permalink
Add SPLUNK_ env prefix support to Instrumentation kind (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
elvis-cai authored Feb 15, 2022
1 parent adb7e39 commit 704ff26
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 3 deletions.
5 changes: 3 additions & 2 deletions apis/v1alpha1/instrumentation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions pkg/instrumentation/podmutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
},
},
},
},
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -28,3 +30,5 @@ spec:
value: "true"
- name: OTEL_INSTRUMENTATION_JDBC_ENABLED
value: "false"
- name: SPLUNK_PROFILER_ENABLED
value: "false"
4 changes: 4 additions & 0 deletions tests/e2e/instrumentation-java/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/instrumentation-nodejs/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -25,4 +27,4 @@ spec:
- name: OTEL_TRACES_EXPORTER
value: otlp_proto_http
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
value: http://localhost:4317
2 changes: 2 additions & 0 deletions tests/e2e/instrumentation-python/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 704ff26

Please sign in to comment.