Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of transaction propagation for empty mono/flux and retry operators #237

Merged

Conversation

veklov
Copy link
Contributor

@veklov veklov commented Mar 7, 2021

This PR fixes two issues with the project reactor instrumentation

  • Transaction is not propagated to Mono.doOnSuccess and Flux.doOnComplete
  • Transaction is lost after Mono.retry* re-subscribes while handling an error

Copy link
Contributor

@tspring tspring left a comment

Choose a reason for hiding this comment

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

Thanks @veklov . This all looks good. Just two minor changes if you don't mind

if (NettyReactorConfig.errorsEnabled) {
// I believe 100% of users disable this as it makes NewRelic to report caught and handled
// exceptions as errors in APM. Is there a real use case for this?
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you be OK with setting the default to false and leaving the config in case someone finds it useful

Copy link
Contributor Author

@veklov veklov Mar 11, 2021

Choose a reason for hiding this comment

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

I just wanted to draw your attention to this. No change is necessary if you think it may be useful for someone.

Please also note that there is a similar lifter in spring-webflux instrumentation module. It reports such error unconditionally and expires tokens immediately after linking (one of the issues being fixed in this PR).

@Trace(async = true, excludeFromTransactionTrace = true)
private void withNRToken(Runnable runnable) {
Token token = currentContext().get(NR_TOKEN);
if (token != null) {
token.linkAndExpire();
}
runnable.run();
}
@Trace(async = true, excludeFromTransactionTrace = true)
private void withNRError(Runnable runnable, Throwable throwable) {
Token token = currentContext().get(NR_TOKEN);
if (token != null && token.isActive()) {
token.linkAndExpire();
NewRelic.noticeError(throwable);
}
runnable.run();
}
}

I use spring webflux server and spring webclient with reactor-netty within the same application. Given that neither token expiration nor error reporting happens after I apply this PR and configure reactor-netty instrumentation to not report errors, it seems that the webflux's lifter is not used. This creates a lot of confusion for understanding the instrumentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the pointer, I'll revisit that instrumentation and see if we can't clean it up some

}

@Test
@Ignore("A test harness check")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove or un-ignore all of the ignored tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@tspring tspring merged commit fd3221f into newrelic:main Mar 11, 2021
@veklov veklov deleted the fix-reactor-empty-operators-and-errors-handling branch March 15, 2021 17:47
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