Skip to content

Resolve Micronaut duplicate transactions/lost custom attributes issues - #3085

Draft
sharvath-newrelic wants to merge 2 commits into
mainfrom
resolve-micronaut-custom-attributes-issue
Draft

Resolve Micronaut duplicate transactions/lost custom attributes issues#3085
sharvath-newrelic wants to merge 2 commits into
mainfrom
resolve-micronaut-custom-attributes-issue

Conversation

@sharvath-newrelic

@sharvath-newrelic sharvath-newrelic commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR aims to resolve a couple of issues where custom attributes and transaction names set from a @ServerFilter were being dropped, and requests sometimes produced two Transaction events for one HTTP call. Two areas have been addressed:

  • PipeliningServerHandler_Instrumentation (all 5 micronaut-http-server-netty-4.x.0 modules): a change was made to call Weaver.callOriginal() before expiring the request token in channelReadComplete(), not after, as expiring first let a synchronous mid-request dispatch run unlinked, which resulted in a phantom transaction.
  • PropagatedContext_Instrumentation (micronaut-core-4.0.0 and 4.3.0): relink the transaction's token across PropagatedContext.wrap(Runnable/Callable), the hop Micronaut uses for @ExecuteOn thread offload. Backed by two small wrapper classes (NRTokenRunnableWrapper, NRTokenCallableWrapper).

Related Github Issue

Resolves #3038 (awaiting potential feedback from user)

Testing

Unit tests have been added (JUnit + Mockito, mockito-inline for static mocking) covering both fixes: token-expiry ordering in the netty handler, and the wrap/relink behavior and its cases in PropagatedContext_Instrumentation and its wrappers.

Passing Micronaut AITs.

@sharvath-newrelic sharvath-newrelic changed the title Fix Micronaut duplication transactions/lost custom attributes issues Resolve Micronaut duplicate transactions/lost custom attributes issues Aug 31, 2026
@codecov-commenter

codecov-commenter commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.85%. Comparing base (11af35c) to head (64636bf).
⚠️ Report is 45 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3085      +/-   ##
============================================
- Coverage     70.92%   70.85%   -0.07%     
- Complexity    10681    10709      +28     
============================================
  Files           871      873       +2     
  Lines         43006    43135     +129     
  Branches       6503     6526      +23     
============================================
+ Hits          30501    30565      +64     
- Misses         9557     9611      +54     
- Partials       2948     2959      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Micronaut @ServerFilter custom attributes missing from transactions (9.4.0) and often see NoOpTransaction

2 participants