dd-trace-java
dd-trace-java copied to clipboard
[DNM] JFR Context Integration PoC
A trivial PoC to provide integration with the JFR Context prototype implementation.
How to build and use
- Clone https://github.com/DataDog/openjdk-jdk21/tree/jb/jfr_context_bp and build the JFR Context prototype OpenJDK 21
- Assuming that the custom OpenJDK build is in <path_to_openjdk> you can build the agent like
JAVA_HOME=$JAVA_8_HOME ./gradlew -Pjfr_context.javac=<path_to_openjdk>/bin/javac :dd-java-agent:shadowJar
- Now you can use the custom dd-java-agent.jar found in
dd-java-agent/build/libs/dd-java-agent-1.22.0-SNAPSHOT.jar
to run the profiler on the patched openjdk to get the JFR events contextualized
Currently the following built-in events are contextualized:
- jdk.ExecutionSample
- jdk.NativeMethodSample
- jdk.ObjectAllocationSample
- jdk.ThreadPark
- jdk.JavaMonitorEnter
- jdk.JavaMonitorWait
- jdk.JavaMonitorInflate
- jdk.SystemGC
- jdk.ObjectAllocationInNewTLAB
- jdk.ObjectAllocationOutsideTLAB
- jdk.ZAllocationStall
- jdk.FileRead
- jdk.FileWrite
- jdk.SocketRead
- jdk.SocketWrite
- jdk.ThreadSleep
!Warning!
This is a very early prototype and the performance may not be as expected (mostly due to conversion between the trace/span id numbers to strings). Do not, I repeat, do not use this in production!!!
@CodiumAI-Agent /review
PR Analysis
(review updated until commit https://github.com/DataDog/dd-trace-java/commit/044feb3b0d3c3ccd0b74b6056dbe83c7d1c2cf9c)
- 🎯 Main theme: Integration of Java Flight Recorder (JFR) Context with Datadog Profiling
- 📝 PR summary: This PR is a proof of concept for integrating the JFR Context prototype implementation with Datadog Profiling. It modifies several classes to enable the use of JFR for profiling context labeling. It also includes changes to handle the initialization of the JFR context before JFR is initialized.
- 📌 Type of PR: Enhancement
- 🧪 Relevant tests added: No
- ⏱️ Estimated effort to review [1-5]: 4, because the PR involves changes in multiple files and the introduction of a new concept (JFR Context), which requires a good understanding of both the existing codebase and the new feature.
- 🔒 Security concerns: No security concerns found
PR Feedback
💡 General suggestions: The PR is a good start for integrating JFR Context into the Datadog Profiling. However, it's important to add tests to validate the new functionality and ensure it doesn't break existing features. Also, the PR should be marked as a draft if it's not ready for production use. Lastly, it would be beneficial to add more comments in the code to explain the purpose and functionality of the new code.
🤖 Code feedback:
relevant file | dd-java-agent/agent-profiling/profiling-uploader/src/main/java/com/datadog/profiling/uploader/ProfileUploader.java |
suggestion | The |
relevant line | // latch.countDown(); |
relevant file | dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java |
suggestion | The |
relevant line | ProfilingContextIntegration ddprof = ProfilingContextIntegration.NoOp.INSTANCE; |
relevant file | dd-java-agent/agent-profiling/profiling-jfr-context/src/main/java/com/datadog/profiling/jfr/context/ContextIntegration.java |
suggestion | The |
relevant line | DDSpanContext.profilingContextAccess = new ProfilerContext.Access() { |
✨ Usage guide:
Overview:
The review
tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
When commenting, to edit configurations related to the review tool (pr_reviewer
section), use the following template:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
With a configuration file, use the following template:
[pr_reviewer]
some_config1=...
some_config2=...
Utilizing extra instructionsThe Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize. Examples for extra instructions:
Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable. |
How to enable\disable automation
meaning the |
Auto-labelsThe
|
Extra sub-toolsThe |
More PR-Agent commands
|
See the review usage page for a comprehensive guide on using this tool.
Persistent review updated to latest commit https://github.com/DataDog/dd-trace-java/commit/044feb3b0d3c3ccd0b74b6056dbe83c7d1c2cf9c