open-telemetry / opentelemetry-operator

Kubernetes Operator for OpenTelemetry Collector
Apache License 2.0
1.15k stars 412 forks source link

Automatic instrumentation of Java agent overrides JAVA_TOOL_OPTIONS #2080

Closed thomaspaulin closed 1 year ago

thomaspaulin commented 1 year ago

The Docker image I'm using uses java -jar as its ENTRYPOINT such that the final CMD expects a jar file. In order to configure the JVM I'm passing values to JAVA_TOOL_OPTIONS, but Otel overrides these with the -javaagent per comments #1744 and #1135. Is there a way to combine the existing options with those Otel injects? From the issues on this repository (#1814 and #1393) it seems that's not yet the case.

iblancasa commented 1 year ago

How are you setting it? Directly as an environment variable or using a ConfigMap?

thomaspaulin commented 1 year ago

Directly as an environment variable in the Dockerfile, then it's being overridden by the environment variables of the Deployment

iblancasa commented 1 year ago

The operator just takes into account the Kubernetes configuration. https://github.com/open-telemetry/opentelemetry-operator/blob/main/pkg/instrumentation/javaagent.go#L45-L53

It cannot check what is inside the container image.

thomaspaulin commented 1 year ago

Turns out the JAVA_TOOL_OPTIONS environment variable was set only in the Dockerfile, and not in the Deployment resource. If I set it on the deployment it merges with the Open Telemetry agent as expected. As such I'll close this issue.