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

UriRoutingContext may not log tracing events #5582

Closed
timothybasanov opened this issue Mar 26, 2024 · 0 comments · Fixed by #5628
Closed

UriRoutingContext may not log tracing events #5582

timothybasanov opened this issue Mar 26, 2024 · 0 comments · Fixed by #5628

Comments

@timothybasanov
Copy link

timothybasanov commented Mar 26, 2024

Not a contribution

org.glassfish.jersey.server.internal.routing.UriRoutingContext class initializes org.glassfish.jersey.message.internal.TracingLogger to TracingLogger.EMPTY due to order of calls from org.glassfish.jersey.servlet.WebComponent#serviceImpl.

Reproduce steps:

  1. Run Jersey 3.1.5 (latest 3.1.x as of March 2024) as a Jetty Servlet filter
  2. Enable event tracing for all requests with:
    property(ServerProperties.TRACING, TracingConfig.ALL.name());
    property(ServerProperties.TRACING_THRESHOLD, TracingLogger.Level.VERBOSE.name());

Expected: UriRoutingContext emits events like MATCH_RESOURCE_METHOD
Actual: No events are emitted due to no-op implementation of a tracingLogger

I suspect that this is due to order of calls coming from WebComponent:

  1. Firstly, a call to TracingLogger.getInstance() sets an EMPTY in UriRoutingContext.tracingLogger. It reads the configuration from a ContainerRequest:
    at org.glassfish.jersey.message.internal.TracingLogger.getInstance(TracingLogger.java:116)
    at org.glassfish.jersey.server.internal.routing.UriRoutingContext.<init>(UriRoutingContext.java:89)
    at org.glassfish.jersey.server.ContainerRequest.<init>(ContainerRequest.java:170)
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:389)
    at org.glassfish.jersey.servlet.ServletContainer.serviceImpl(ServletContainer.java:377)
    at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:552)
    at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:493)
    at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:430)
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
    
  2. Secondly, a call to TracingUtils.initTracingSupport() initializes a org.glassfish.jersey.message.internal.TracingLogger#PROPERTY_NAME in a ContainerRequest. It's too late for a UriRoutingContext to take advantage of it:
    at org.glassfish.jersey.server.TracingUtils.initTracingSupport(TracingUtils.java:65)
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:206)
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
    at org.glassfish.jersey.servlet.ServletContainer.serviceImpl(ServletContainer.java:377)
    at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:552)
    at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:493)
    at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:430)
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
    
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 a pull request may close this issue.

1 participant