Skip to content

Include advice class name in instrumentation exception handler log#11457

Open
amarziali wants to merge 2 commits into
masterfrom
andrea.marziali/logger++
Open

Include advice class name in instrumentation exception handler log#11457
amarziali wants to merge 2 commits into
masterfrom
andrea.marziali/logger++

Conversation

@amarziali
Copy link
Copy Markdown
Contributor

What Does This Do

Refactors ExceptionHandlers.defaultExceptionHandler into a factory that takes the advice class FQN, and changes the bytecode it emits so the resulting log line is:

Failed to handle exception in instrumentation for com.example.InstrumentedClass (com.example.SomeAdvice)

instead of:

Failed to handle exception in instrumentation for com.example.InstrumentedClass

The existing ... for <instrumentedClass> prefix is preserved (so existing log searches / dashboards keep working);

Please note that now the stack manipulation is compound and made of two part:

  1. One little TextConstant that's allocated for each Advice when they are installed (it's small and cheap, just doing a LDC)
  2. The existing logging advice that's shared among all the installed advices

The new logging bytecode has been adapted to consume the advice name from the stack and weave it into the log message at runtime via two String.concat calls.

This is very useful to understand which advice specifically triggered the error for the telemetry. Unfortunately there is no easy way to make distinction between the OnMethodEnter/OnMethodExit but this is a nice step forward in improving the message.

Motivation

Additional Notes

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added the type: enhancement Enhancements and improvements label May 26, 2026
@amarziali amarziali requested a review from a team as a code owner May 26, 2026 12:43
@amarziali amarziali added the comp: core Tracer core label May 26, 2026
@amarziali amarziali requested review from mcculls and mhlidd May 26, 2026 12:43
@amarziali amarziali added the tag: do not merge Do not merge changes label May 26, 2026
@datadog-datadog-prod-us1-2
Copy link
Copy Markdown
Contributor

datadog-datadog-prod-us1-2 Bot commented May 26, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 8 Pipeline jobs failed

Run system tests | main / End-to-end #7 / vertx3 7   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). 1 failed test due to assertion error: Unexpected error in telemetry logs. Assertion failed for message 'Failed to handle exception in instrumentation for io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder'.

Run system tests | main / End-to-end #8 / vertx4 8   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). 1 failed test. AssertionError: assert not [{'count': 1, 'level': 'DEBUG', 'message': 'Failed to handle exception in instrumentation for io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder'...}]

DataDog/apm-reliability/dd-trace-java | java-startup-parallel-check-slo-breaches   View in Datadog   GitLab

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. No Markdown threshold comparison report could be generated due to missing scenarios and a missing GitHub token file.

View all 8 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: cae88a2 | Docs | Datadog PR Page | Give us feedback!

@amarziali
Copy link
Copy Markdown
Contributor Author

Depends somehow on #11268 that will fix the exception that's excluded in system tests but now the text slightly changed :)

Copy link
Copy Markdown
Contributor

@mhlidd mhlidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. Just some nit comments for clarity since I got confused following 😅

Co-authored-by: mhlidd <matthew.li@datadoghq.com>
@amarziali amarziali requested a review from mhlidd May 27, 2026 13:08
Copy link
Copy Markdown
Contributor

@mhlidd mhlidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: do not merge Do not merge changes type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants