-
Notifications
You must be signed in to change notification settings - Fork 873
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 nested http.route #8282
Fix nested http.route #8282
Conversation
...etry/javaagent/instrumentation/spring/webflux/v5_0/server/HandlerAdapterInstrumentation.java
Show resolved
Hide resolved
self-resolved :) |
...rc/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for figuring out how to add a test for this!
"nested path"), // TODO (heya) move it to webflux test module after this has been converted to | ||
// a class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @siyuniu-ms
@@ -66,7 +66,7 @@ public static void methodEnter( | |||
Context parentContext = Context.current(); | |||
|
|||
HttpRouteHolder.updateHttpRoute( | |||
parentContext, HttpRouteSource.CONTROLLER, httpRouteGetter(), exchange); | |||
parentContext, HttpRouteSource.NESTED_CONTROLLER, httpRouteGetter(), exchange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a brief comment here about why NESTED_CONTROLLER is needed?
...etry/javaagent/instrumentation/spring/webflux/v5_0/server/HandlerAdapterInstrumentation.java
Outdated
Show resolved
Hide resolved
I haven't looked into the test code, but there was a single test failure which suggests an edge case maybe:
|
Co-authored-by: Trask Stalnaker <[email protected]>
…om/heyams/opentelemetry-java-instrumentation into heya/fix-spring-webflux-http-route
Thanks! It should be fixed now. |
Thanks @heyams ! |
this will replace #8112
I will try my best to explain the fix:
HttpRouteHolder.updateHttpRoute will get called twice.
1st is triggered by the
RateOnSuccess
with route/{id:[A-Z0-9\-]+}
2nd time is triggered by the
HandlerAdapterInstrumentation.onMethodEnter
with the full route including the nested paths.When using
HttpRouteSource.CONTROLLER
, it hasuseFirst
set to true.2nd time didn't do anything.
When using '
HttpRouteSource.NESTED_CONTROLLER
, it hasuseFirst
set to false.2nd time it will update the route to
/api/accounts/{id:[A-Z|0-9|\-]+}
.I will try to come up with a test for it if it's feasible.here is the test app https://github.com/heyams/otel-http-route-sample