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 spring-webflux-5 http.route #8112

Closed

Conversation

heyams
Copy link
Contributor

@heyams heyams commented Mar 22, 2023

relate to #5239

http.route is populated correctly:

getAttributes={http.flavor="1.1", http.method="GET", http.route="/api/accounts/{id:[A-Z|0-9|\-]+}", http.scheme="http", http.status_code=200, http.user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.41", net.host.name="localhost", net.host.port=8080}

@heyams heyams changed the title Fix spring-webflux-5 span name Fix spring-webflux-5 http.route Mar 25, 2023
@heyams heyams marked this pull request as ready for review March 25, 2023 05:34
@heyams heyams requested a review from a team as a code owner March 25, 2023 05:34
@heyams heyams marked this pull request as draft March 25, 2023 16:27
@heyams heyams marked this pull request as ready for review March 27, 2023 18:27
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void methodExit(
@Advice.This RouterFunction<?> thiz,
@Advice.Return(readOnly = false) Mono<HandlerFunction<?>> result,
@Advice.Thrown Throwable throwable) {
@Advice.Thrown Throwable throwable,
@Advice.Local("otelContext") Context context,
Copy link
Member

Choose a reason for hiding this comment

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

context is not used anywhere within this method; the span started in the OnMethodEnter advice does not seem to be ended. Is that correct? Is this span needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

context is not used here. i can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

span is needed for initializing the ServletContextPath. I have updated the code to end advice.

Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need to create a span to use ServletContextPath. The ServletContextPath is supposed to be initialized somewhere in the application server layer, in a different instrumentation; here you're just reading whatever value was set before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mateuszrzeszutek after some further investigation, http.route is correct when otel.instrumentation.common.experimental.controller-telemetry.enabled is false with my change and http.route is incorrect when controllerTelemetryEnabled is true.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

hey @heyams! I think it would help if you can add a test that exhibits the problem, and is fixed by your change

return;
}

context = instrumenter().start(parentContext, request);
Copy link
Member

Choose a reason for hiding this comment

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

it's not clear to me why creating a new span?

@trask trask added this to the v1.25.0 milestone Apr 6, 2023
@trask trask force-pushed the heya/fix-spring-5-webflux-route branch from cb2c04c to 7a99d7b Compare April 11, 2023 21:06
@trask trask marked this pull request as draft April 11, 2023 21:07
@heyams heyams mentioned this pull request Apr 12, 2023
@trask trask removed this from the v1.25.0 milestone Apr 13, 2023
@heyams heyams closed this Apr 13, 2023
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.

None yet

4 participants