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

Not able to link Trace to Profile with "otel-profiling-java" package #15

Open
Vaibhav-1995 opened this issue Jan 28, 2025 · 4 comments
Open

Comments

@Vaibhav-1995
Copy link

Vaibhav-1995 commented Jan 28, 2025

Bug

As per below document once we add "otel-0.11.0.jar" in application image it will automatically assign profiles with span IDs and with that after making mentioned setting in Tempo data source we will be able to see Trace to Profile linkage.
https://grafana.com/docs/pyroscope/latest/configure-client/trace-span-profiles/java-span-profiles/

But it is not working in our setup since our application image is build through CI-CD pipeline and when we add below dependency and build our image the "otel-0.11.0.jar" gets added in "app.jar" in application image and not as separate jar file in any of image directory. Due to which this setup is not working in our case and not able to link Trace to Profile.

<dependency>
    <groupId>io.pyroscope</groupId>
    <artifactId>otel</artifactId>
    <version>0.11.0</version>
</dependency>

Also added ENV OTEL_JAVAAGENT_EXTENSIONS=./pyroscope-otel.jar in application deployment but still that jar is not getting started from app.jar.

Expected Behavior

As mentioned in document, we should be able to link Trace to Profile once "otel-0.11.0.jar" is added to app image irrespective of how it gets added (in this case it is getting added in app.jar - when extracted app.jar it is present on path /BOOT-INF/lib/otel-0.11.0.jar)

Environment

  • Infrastructure: Kubernetes
  • Deployment tool: helm

Additional Context

As tested same is working locally and able to link Trace to Profile if we create Dockerfile and add "otel-0.11.0.jar" mannually as mention in documentation beacuse it gets added as a separate jar file on mentioned path and also ENV OTEL_JAVAAGENT_EXTENSIONS=./pyroscope-otel.jar starts it.

Question

How can we achieve this with mentioned setup as our app image is getting build through pipeline and otel-0.11.0.jar in geeting added in app.jar ? Also how can we start that jar which is in app.jar on path /BOOT-INF/lib/otel-0.11.0.jar ?

@Vaibhav-1995
Copy link
Author

Hi Team, Any update?

@Vaibhav-1995
Copy link
Author

Hi Team,

Could you please check on this? We are stuck on it.

@kolesnikovae kolesnikovae transferred this issue from grafana/pyroscope Feb 3, 2025
@aleks-p
Copy link
Contributor

aleks-p commented Feb 3, 2025

Hi @Vaibhav-1995

I don't think this is directly possible. What could work is building a custom OpenTelemetry auto-instrumentation jar that has the extension bundled inside. Then, you should be able to avoid adding it to your application entirely. We haven't tried this though, and we don't provide this jar currently.

You can find some info and guidance on this here: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ffaddc0ed6fec594e88de79a976dc8f10ae799f/examples/extension/README.md?plain=1#L29, if you want to try to build such an agent yourself.

Here is where the loading of embedded extensions happens:
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ffaddc0ed6fec594e88de79a976dc8f10ae799f/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ExtensionClassLoader.java#L79

In the last link you'll notice that the extension jar is extracted from the agent jar to a temporary location and loaded as usual. If you have some flexibility in your setup, you could facilitate a similar approach as well.

@Vaibhav-1995
Copy link
Author

Thanks @aleks-p

Will check one above approch if it's possible from our end and will get back on it.

Additionaly, to make it simplier do you have any idea if we can bundle this jar directly with java-autoinstrumentation image in docker file and can use it in any way as we are already using java-autoinstrumentation for tracing so that image is getting injected in app pod and also it injects javaagent.jar by creating otel-auto-instrumentation-java directory.

So if we can add otel-0.11.0.jar in that image and can inject it in same otel-auto-instrumentation-java directory, I think it may work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants