Skip to content

Conversation

@jaydeluca
Copy link
Member

@jaydeluca jaydeluca commented Dec 4, 2025

Related to #14906

The spring-cloud-starter-gateway artifact split into two:

  • spring-cloud-starter-gateway-server-webmvc
  • spring-cloud-starter-gateway-server-webflux

When I tried to update the muzzle config to include both new artifacts, I hit some muzzle errors, so I split out webmvc into its own module. I also noticed that we didn't have test coverage for webmvc, so I added some, and realized that it wasn't working so I added some new instrumentation. If we would prefer that I undo all of that and handle it in a separate PR, just let me know.

@jaydeluca jaydeluca marked this pull request as ready for review December 4, 2025 21:30
@jaydeluca jaydeluca requested a review from a team as a code owner December 4, 2025 21:30
Comment on lines 25 to 29
@Override
public ElementMatcher<ClassLoader> classLoaderOptimization() {
return hasClassesNamed(
"org.springframework.cloud.gateway.server.mvc.handler.GatewayDelegatingRouterFunction");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not needed when matching classes based on just name

}

try {
Field routeIdField = gatewayRouterFunction.getClass().getDeclaredField("routeId");
Copy link
Contributor

Choose a reason for hiding this comment

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

usually when we use reflection we try to do the reflective lookup only once and reuse the Field/Method. Isn't the gatewayRouterFunction here always GatewayDelegatingRouterFunction? If it is you could look up the field in the static initializer of the class. An other option would be to instrument that class and copy route value into a virtual field that you could read here.


Optional<Object> requestUrlOpt = request.attribute(MvcUtils.GATEWAY_REQUEST_URL_ATTR);
requestUrlOpt.ifPresent(
uri -> serverSpan.setAttribute(ROUTE_URI_ATTRIBUTE, ((URI) uri).toASCIIString()));
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason you didn't wish to just use the toString() of the uri?

Copy link
Member Author

Choose a reason for hiding this comment

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

no good reason, updated thanks


@Test
void gatewayRouteMappingTest() {
testGatewayRouteMapping();
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason you didn't add @Test to the super class method?

Copy link
Member Author

Choose a reason for hiding this comment

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

at one point i was overriding the method but thats no longer needed, thanks

Comment on lines 6 to 7
compileOnly("io.opentelemetry:opentelemetry-api")
compileOnly("io.opentelemetry:opentelemetry-api-incubator")
Copy link
Contributor

Choose a reason for hiding this comment

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

aren't these already available through otel.javaagent-instrumentation?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes thank you

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.

3 participants