Skip to content

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

Merged
merged 5 commits into from
Mar 27, 2024

Conversation

Rperry2174
Copy link
Contributor

Updates grafana agent java example to have some more details explaining what the example actually does and how it works

@Rperry2174 Rperry2174 requested a review from a team as a code owner March 26, 2024 23:57
Copy link
Contributor

@knylander-grafana knylander-grafana left a 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.

@knylander-grafana knylander-grafana added the type/docs Improvements for doc docs. Used by Docs team for project management label Mar 27, 2024
apply code changes

Co-authored-by: Kim Nylander <[email protected]>
Comment on lines 11 to 21
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.
Copy link
Contributor

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.
Copy link
Contributor Author

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)?

Copy link
Contributor

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?)

@Rperry2174 Rperry2174 merged commit c306337 into main Mar 27, 2024
@Rperry2174 Rperry2174 deleted the update-grafana-agent-java-docs branch March 27, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Improvements for doc docs. Used by Docs team for project management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants