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

OpenTelemetry Automatic instrumentation - General usability question #8227

Closed
banandh opened this issue Apr 6, 2023 · 10 comments
Closed

OpenTelemetry Automatic instrumentation - General usability question #8227

banandh opened this issue Apr 6, 2023 · 10 comments
Labels
needs author feedback Waiting for additional feedback from the author stale

Comments

@banandh
Copy link

banandh commented Apr 6, 2023

I'm using automatic instrumentation in my springboot app.

  1. Would like to return the traceId being generated from Opentelemetry agents in my application response header so it will be used for request tracing.

  2. Currently adding -javaagent for automatic instrumentation, would like to include this javaagent jar in classpath and enforce this instrumentation via manifest.mf

SpringBoot maven plugin creates a executable jar , in that i wanted to include this Launcher-Agent-Class to point to the opentelemetry agent class so that it can be automatically added whenever the jar is executed

@banandh banandh added the bug Something isn't working label Apr 6, 2023
@jkwatson jkwatson transferred this issue from open-telemetry/opentelemetry-java Apr 6, 2023
@trask
Copy link
Member

trask commented Apr 6, 2023

Would like to return the traceId being generated from Opentelemetry agents in my application response header so it will be used for request tracing.

this isn't supported out-of-the-box since it's not part of the OpenTelemetry specification (yet?), but you could implement it using a javaagent extension using the new HttpServerResponseCustomizer implemented in #7990 and #8095

SpringBoot maven plugin creates a executable jar , in that i wanted to include this Launcher-Agent-Class to point to the opentelemetry agent class so that it can be automatically added whenever the jar is executed

I'm not sure if anyone has tried this. It may not work since we add the javaagent jar to the bootstrap classpath, and that could be problematic if the javaagent classes are in an uber jar. Let us know how if you have any success / run into any problems.

@trask
Copy link
Member

trask commented Apr 6, 2023

@banandh
Copy link
Author

banandh commented Apr 10, 2023

also check out https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/runtime-attach

This really helps. Will try out :)

@mateuszrzeszutek mateuszrzeszutek added needs author feedback Waiting for additional feedback from the author and removed bug Something isn't working labels Apr 11, 2023
@banandh
Copy link
Author

banandh commented Apr 11, 2023

specification

May be I missed to convey my requirement clearly. What I wanted is "use automatic instrumentation and get the traceId inside the service either by adding opentelemetry api jars as dependency or someother way".

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Apr 11, 2023
@mateuszrzeszutek
Copy link
Member

May be I missed to convey my requirement clearly. What I wanted is "use automatic instrumentation and get the traceId inside the service either by adding opentelemetry api jars as dependency or someother way".

We have that feature already -- you can add the opentelemetry-api dependency to your app, and use the Span.current() to retrieve the current span in your code. (you can also use the OTel API to add any manual instrumentation that you want, and that the agent does not provide out of the box)

@laurit
Copy link
Contributor

laurit commented Apr 12, 2023

I haven't tried Launcher-Agent-Class myself, but I think the easiest way to make it work is probably to package the agent jar inside your app as a jar file and use a custom launcher agent class that extracts the agent jar from your jar, adds it to classpath somehow(Instrumentation.appendToBootstrapClassLoaderSearch or new URLClassLoader), loads the agent main class (io.opentelemetry.javaagent.OpenTelemetryAgent) and calls agentmain or premain

@banandh
Copy link
Author

banandh commented Apr 17, 2023

custom launcher agent class

Can you point some examples. Not sure whether , i understood it rightly

@banandh
Copy link
Author

banandh commented Apr 17, 2023

also check out https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/runtime-attach

This really helps. Will try out :)

This runtime attach has a limitation "The application is running on a JRE (a JDK is necessary, see raphw/byte-buddy#374)". Usually runtime contains JRE not the JDK so it can fail in higher environment

@laurit
Copy link
Contributor

laurit commented Apr 17, 2023

custom launcher agent class

Can you point some examples. Not sure whether , i understood it rightly

I don't believe anybody has tried this before, so there is no sample code.

@trask trask added the needs author feedback Waiting for additional feedback from the author label Aug 10, 2023
@github-actions
Copy link
Contributor

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.

@github-actions github-actions bot added the stale label Aug 17, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs author feedback Waiting for additional feedback from the author stale
Projects
None yet
Development

No branches or pull requests

4 participants