-
Notifications
You must be signed in to change notification settings - Fork 879
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
Java Agent ignoring environment variables and java parameters for service name #12820
Comments
I am able to observe the agent picking up the environment variable I don't see you passing a javaagent in your command, how are you using the instrumentation? |
Hey @jaydeluca - Thanks for your response. I accidentally stripped the -javaagent:path/to/jar command because it had a username in the path, but edited it for clarity now. I did double check that the -javaagent param is the first param after the java command. Inside the otel.properties files I have otel.service.name defined:
In the app logs
Or, if I try
I see that the process arg is there, and even being capture as a process arg, but I still see service.name="unknown_service:java" |
It feels like this issue may be specific to my environment due to our jdk version?
But I assumed I would see that same error for the autoconfiguration class if that's why it wasn't catching specific parameters or env vars e.g. |
the property for the javaagent config file should be You could also try using the new declarative-config approach |
Ah, thanks - tried again with |
|
@laurit Ah - thank you, that appears to have been the fix, as after removing that line I do see service names in my traces! |
There is some description of Going back the config from the original issue, you had (formatted as a list for readability):
The way this worked:
|
Hey @jack-berg thanks for the response. I originally went down this path because I noticed traces published at start up indicating the agent was attempting to call AWS/GCP metadata services. I picked those two providers from the list here: https://opentelemetry.io/docs/languages/java/configuration/#resourceprovider because I was trying to pick the minimal resource providers for a faster startup time, and figured I would add more if what they had wasn't sufficient. Since enabled.resource.providers is a strict allow list, this behavior makes sense/isn't a bug - but I read the note and list here as being a comprehensive list of all possible resource providers rather than only those in -contrib, so I didn't realize I was disabling built in providers |
Just ran into the same thing today, never would have occurred to me a resource provider would prevent the OTEL service name attribute from being set and thus mangling under which service my traces/metrics would be routed to. |
I agree this is confusing. Luckily it looks like the (still experimental) declarative configuration is much clearer when it comes to including and excluding resource attributes: https://github.com/open-telemetry/opentelemetry-configuration/blob/60a2d91aa03b94b1bd34b85cc349a83ed9f35527/examples/kitchen-sink.yaml#L439-L455 you can start using declarative configuration already if you would like, here's an example with the java agent: https://github.com/open-telemetry/opentelemetry-java-examples/blob/main/javaagent/sdk-config.yaml |
Just tried this (as per the solution mentioned above) and it still didn't work, maybe there is another one I need for it to work with -D params?
I think I might just go for the exclude list now and remove the ones that add all the attributes I don't want (not ideal as I want to tightly control what attributes get added and don't want new ones appearing without us opting in) |
Describe the bug
Hi folks, I am trying to instrument my service with the Otel java agent. For some reason however, the agent appears to be ignoring specific parameters or environment variables, such as
OTEL_SERVICE_NAME
.Steps to reproduce
This happens when invoking the app with
Expected behavior
The otel service name to be validator_service in Datadog, and traces being produced
Actual behavior
Traces are produced, but only for
unknown_service:java
in Datadog. I can see the configuration parameters reflected in the telemetry as process args.When I enable debug logs, I see the log line:
So it seems the autoconfigured SDK builder is being created and picking up some attributes, but not all
Javaagent or library instrumentation version
2.10.0
Environment
JDK: jdk1.8.0_173
OS: RHEL7
Additional context
No response
The text was updated successfully, but these errors were encountered: