grafana / JPProf

Go Pprof but for Java runtime.
Apache License 2.0
69 stars 5 forks source link

Package JPProf as a Java agent #20

Open ahus1 opened 2 years ago

ahus1 commented 2 years ago

It would be great to package JPProf as a Java agent, so I can specify it on the command line of an existing application and don't need to change my applications.

java -javaagent:jpprof-javaagent.jar -jar myapp.jar

Other frameworks like open telemetry do this already. See https://github.com/open-telemetry/opentelemetry-java-instrumentation, and looking at the standalone example this should hopefully be possible.

There would be the need to pass the port as a parameter, for example as a system property (-Dgrafana.jpprof.port=xxx).

Thanks!

ahus1 commented 1 year ago

A friend showed me kubectl-flame (https://github.com/yahoo/kubectl-flame) which uses a separate container to fetch the profiling information, which also works for Java containers. This would avoid running the Java container itself as a privileged pod and wouldn't require changing existing deployments.

Any thoughts on that approach? Thanks!

fstab commented 1 year ago

Hi Alexander, I agree that having a profiler that you can just attach to any application without requiring code change would be great. We have this on our roadmap, but it might take a while until it gets done.

ahus1 commented 1 year ago

Hi Fabian - long time no see! Good to know that this is on the road map, will keep an eye on it!

smagnacco commented 1 year ago

Hey, have you seen that https://github.com/dpsoft/ap-agent is an agent that already support pprof and expose an api?