-
Notifications
You must be signed in to change notification settings - Fork 660
docs: Update grafana agent java example readme #3136
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating the docs. I've added some minor suggestions.
apply code changes Co-authored-by: Kim Nylander <[email protected]>
Java applications can be profiled via Pyroscope using three methodologies. The example emphasizes the first method, showcasing the attachment of the Pyroscope profiler as a `javaagent`. | ||
|
||
Refer to the [official documentation](https://grafana.com/docs/pyroscope/latest/configure-client/grafana-agent/java/) for an in-depth understanding and additional configuration options for Java profiling with the Grafana Agent. | ||
|
||
The three methodologies are as follows: | ||
|
||
1. **Java Agent** (this example): Attach the Pyroscope profiler as a `javaagent` to a running process, initializing the profiler at application startup without source code modifications or extra dependencies. Manage configuration using Java parameters or environment variables. | ||
|
||
2. **OTel Integration** ([docs](https://grafana.com/docs/pyroscope/next/configure-client/trace-span-profiles/java-span-profiles/)): Utilize the OTel integration as an extension to `otel-java-instrumentation`, in conjunction with `opentelemetry-javaagent` to link java profiles with trace spans. This method is suitable for applications already using OpenTelemetry. | ||
|
||
3. **Direct Dependency** ([docs](https://grafana.com/docs/pyroscope/next/configure-client/language-sdks/java/)): Integrate Pyroscope directly within your application's code to allow dynamic profiler management. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example doesn't show the first method (or the other 2). In this approach the grafana agent attaches to the running Java processes and auto-instruments them (starts profiling) with async-profiler. Perhaps remove this section altogether and add a note in the next section about how this works.
To clarify, the first method mentioned above requires changing the command to start the java application, an example of this is
ADD https://github.com/grafana/pyroscope-java/releases/download/v0.13.0/pyroscope.jar /opt/app/pyroscope.jar | |
CMD sh -c "exec java -Dserver.port=${RIDESHARE_LISTEN_PORT} -javaagent:pyroscope.jar -jar ./build/libs/rideshare-1.0-SNAPSHOT.jar" |
|
||
### Grafana Agent and async-profiler | ||
|
||
The Grafana Agent automates Java process discovery for profiling, streamlining the setup per application. It enables precise and targeted profiling configurations through the Grafana Agent settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aleks-p is this more correct (or if not what would you change this to)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a change that makes it more accurate imo. Take a look and change wording as needed (we might want another pass from @knylander-grafana as well?)
Updates grafana agent java example to have some more details explaining what the example actually does and how it works