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
HttpRequestTags depends on both jakarta and javax Servlet variants #3804
Comments
@countableSet the I believe that replacing |
@bclozel I might be misunderstanding you but I am using the HttpJakartaServletRequestTagsProvider interface and if you look at the implementation version of DefaultHttpJakartaServletRequestTagsProvider it calls public class DefaultHttpJakartaServletRequestTagsProvider implements HttpJakartaServletRequestTagsProvider {
@Override
public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response) {
return Tags.of(HttpRequestTags.method(request), HttpRequestTags.status(response),
HttpRequestTags.outcome(response));
}
} HttpRequestTags has implementations for jakarta, however, I can't use them because of the javax compile failure. I suppose copy pasta these methods into my project but it is kinda annoying. public static Tag method(jakarta.servlet.http.HttpServletRequest request) {
return (request != null) ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN;
} If you take look at the branch I referenced it adds a test to Could you please take a second look at the issue? Thanks! It would be nice to break up the javax and jakarta methods into different class to avoid compiler failures. |
Thanks @countableSet I missed that part. In this case Jetty is not really central to this issue. I'll reopen it so we can reconsider this choice. |
@bclozel thanks so much! I also made an isolated project if that helps here, with different branches for jakarta and javax. I was also curious if the issue happens in reverse, it it does as well. If you try and use
|
Applications should ensure that they rely on I've marked this for the next feature release as it's too late to take care of this now for 1.11. |
Prior to this commit, `HttpRequestTags` would provide Tags for both "javax.*" and "jakarta.*" variants of `HttpServletRequest`. While the `HttpServletRequestTagsProvider` and `HttpJakartaServletRequestTagsProvider` are separate interfaces, they both use `HttpRequestTags` and import all types exposed on its methods. It is strongly advised not to import both "javax.*" and "jakarta.*" variants in a typical application and the current arrangement prevents this best practice. This commit deprecates Jakarta methods variants in `HttpRequestTags` and moves them to `HttpJakartaServletRequestTags`. This allows a clean dependency setup for Jakarta apps and a migration path for all in the meantime. Closes micrometer-metricsgh-3804
Describe the bug
When
javax.*
dependency isn't included in the project, the classio.micrometer.core.instrument.binder.http.HttpRequestTags
fails to compile when usingimplementation("io.micrometer:micrometer-jetty11:$micrometerVersion")
version of TimeHandler.Environment
To Reproduce
How to reproduce the bug:
I added a test case to the
io.micrometer.jetty11.TimedHandlerTest
(see branch) which reproduces the issue.Expected behavior
Should compile without issues in a project without
javax.*
dependencies.Additional context
Tried with a lambda:
and custom class
with the same problem.
However, using the constructor without the provider works fine.
The text was updated successfully, but these errors were encountered: