Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SPLUNK_ env prefix support to Instrumentation kind #709

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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