Skip to content

Log a warning when retransforming already-loaded classes fails - #12673

Closed
gibkim wants to merge 2 commits into
DataDog:masterfrom
gibkim:gibkim/warn-on-retransform-failure
Closed

gibkim wants to merge 2 commits into
DataDog:masterfrom
gibkim:gibkim/warn-on-retransform-failure

Conversation

@gibkim

@gibkim gibkim commented Sep 29, 2026 •

Copy link
Copy Markdown

What Does This Do

Registers RedefinitionLoggingListener at all log levels, not only when debug logging is on. When a retransformation batch fails and debug logging is off, it logs one warning with the batch size and the cause. Debug logging still logs the full class list and stack trace, as before.

Motivation

In #12540 the whole instrumentation install was aborted and no spans were produced, but nothing was logged at the default level. The only hint was Exception while retransforming 574 classes with -Ddd.trace.debug=true. Because already-loaded classes are retransformed in a single batch, one failure leaves all of them uninstrumented.

#12610 fixed that specific cause. This change makes any similar failure visible, so it can be found without debug logging.

Additional Notes

  • The listener is now added once on the main builder chain, so the debug block only adds TransformLoggingListener.
  • The warning is logged once per failed batch. With the default batch allocator there is a single batch, so at most one line per install.
  • RedefinitionLoggingListenerForkedTest covers the non-debug path. It is a forked test because AgentInstaller.DEBUG is fixed when the class is initialized. The test fails without the production change.
  • Following AGENTS.md: this PR was written with an AI coding assistant (Claude Code) and reviewed by me. I ran the repo's techdebt and perf-review skills on the diff: techdebt found the redundant debug-block registration (fixed), perf-review found nothing (install-time path only). I can't add labels as an external contributor, so could a maintainer add tag: ai generated and the comp:/type: labels?

@gibkim
gibkim requested a review from a team as a code owner September 29, 2026 00:11
@gibkim
gibkim requested review from bric3 and removed request for a team September 29, 2026 00:11
@gibkim
gibkim marked this pull request as draft September 30, 2026 06:04
@gibkim
gibkim marked this pull request as ready for review September 30, 2026 06:05
benjamin.a added 2 commits October 27, 2026 10:04
RedefinitionLoggingListener was only registered with debug logging,
so a failed retransformation batch was silent at the default level.
Because every already-loaded class is retransformed in a single batch,
one failure leaves all of them uninstrumented, as seen in DataDog#12540.

Register the listener always, and log a one-line warning with the
batch size and cause when debug logging is off. Debug logging keeps
the full class list and stack trace.
RedefinitionLoggingListener is now registered on the main builder
chain, so the debug block only needs TransformLoggingListener.
@gibkim
gibkim force-pushed the gibkim/warn-on-retransform-failure branch from 0292dff to db9ada7 Compare October 27, 2026 01:09
@mcculls

mcculls commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Hi @gibkim - thanks for the suggestion

I am wary about changing this log message to WARN because we usually only produce warnings for things the user has control over. In this case there isn't enough actionable information for the user to solve the issue themselves, which means they would need to consult with us which would typically involve enabling debug mode anyway.

We also have other changes in-flight for AOT which would make this logging change less useful.

@gibkim

gibkim commented Oct 31, 2026

Copy link
Copy Markdown
Author

Thanks for the explanation, that makes sense. I'll close this and keep an eye on the AOT changes.

@gibkim gibkim closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants