Skip to content

Conversation

@jbachorik
Copy link
Contributor

@jbachorik jbachorik commented Jan 27, 2026

What Does This Do

Adds support for profiling in GraalVM native images built with Quarkus, and includes a smoke test to prevent regressions.

Changes:

  1. Fix GraalVM native image build for profiler classes - Adds proper native-image configuration to defer profiler class initialization to runtime, fixing ClassNotFoundException: BufferWriter9 during Quarkus native builds
  2. Use JMX for crashtracking in native images - Switches crashtracking initialization to use JMX in native image context
  3. Add profiling smoke test for Quarkus native images - Extends the existing Quarkus native smoke test to validate profiling works correctly

Motivation

Issue #10446 reported that Quarkus native image builds failed with:

Error: Class initialization of com.datadoghq.profiler.ThreadContext failed
Caused by: java.lang.ClassNotFoundException: com.datadoghq.profiler.BufferWriter9

This occurred because GraalVM native-image performs class initialization at build time by default. Profiler classes like ThreadContext, BufferWriter, BufferWriter8, and BufferWriter9 depend on runtime state and must be deferred to runtime initialization.

The smoke test ensures:

  • Native image builds successfully with profiling enabled (no ClassNotFoundException)
  • Application starts without agent initialization errors
  • Profiler produces JFR files with execution samples at runtime

Additional Notes

  • The smoke test only runs with GraalVM (-PtestJvm=graalvm21)
  • Test extends QuarkusSlf4jSmokeTest to reuse endpoint configuration
  • Follows the same pattern as SpringBootNativeInstrumentationTest

Contributor Checklist

Jira ticket: PROF-13580

jbachorik and others added 2 commits January 27, 2026 10:04
Defer initialization of java-profiler BufferWriter classes to runtime
to fix ClassNotFoundException during native image build.

Fixes #10446

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Native images don't support the native ddprof library, so use
JMX-based flag access instead to keep crashtracking functional.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jbachorik jbachorik added type: enhancement Enhancements and improvements comp: testing Testing comp: profiling Profiling tag: ai generated Largely based on code generated by an AI or LLM labels Jan 27, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: profiling Profiling comp: testing Testing tag: ai generated Largely based on code generated by an AI or LLM type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants