Skip to content

Provide a URI tag for HTTP requests handled by MessageDispatcherServlet #15390

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

Open
SorokinStanislav opened this issue Dec 5, 2018 · 10 comments
Labels
status: blocked An issue that's blocked on an external project change type: enhancement A general enhancement

Comments

@SorokinStanislav
Copy link

SorokinStanislav commented Dec 5, 2018

Trying to use http_server_requests actuator metrics (Spring Boot 2.1.1) for web-method annotated by

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getName")
@ResponsePayload
@Timed

in @Endpoint class.

Do request like this:

POST /soap/getPerson HTTP/1.1
Host: localhost:1882
Content-Type: text/xml
Cache-Control: no-cache

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://example.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:personRequest>
         <id>18</id>
      </ser:personRequest>
   </soapenv:Body>
</soapenv:Envelope>

And in prometheus I see:

http_server_requests_seconds_count{exception="None",method="POST",outcome="SUCCESS",status="200",uri="UNKNOWN",} 1.0
http_server_requests_seconds_sum{exception="None",method="POST",outcome="SUCCESS",status="200",uri="UNKNOWN",} 0.290792324
http_server_requests_seconds_max{exception="None",method="POST",outcome="SUCCESS",status="200",uri="UNKNOWN",} 0.290792324

This issue like a micrometer issue #431, but there were URI cutting and not UNKNOWN. This is because of update WebMvcTags solving #12447.

So as I can see, new uri method doesn't support MessageDispatcherServlet which request does not contain BEST_MATCHING_PATTERN_ATTRIBUTE attribute.

You can reproduce this and look at whole code at my repo.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 5, 2018
@SorokinStanislav SorokinStanislav changed the title URI in actuator metrics always "UNKNOWN" for SOAP-service methods URI in actuator metrics is always "UNKNOWN" for SOAP-service methods Dec 5, 2018
@wilkinsona wilkinsona changed the title URI in actuator metrics is always "UNKNOWN" for SOAP-service methods Provide a URI tag for HTTP requests handled by MessageDispatcherServlet Dec 6, 2018
@wilkinsona
Copy link
Member

wilkinsona commented Dec 6, 2018

Thanks for the suggestion, but I'm not sure that the URI is of much value when using SOAP as it won't tell you that much. It'll only provide details of the service that's being called and won't provide any information about the specific request which is in the body. Perhaps I have misunderstood? What did you expect to appear in the URI tag?

Overall, this feels to me like this may be better handled in Spring Web Services as part of SWS-1024. /cc @gregturn

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Dec 6, 2018
@SorokinStanislav
Copy link
Author

SorokinStanislav commented Dec 6, 2018

@wilkinsona, Thank you for your answer!
I've updated my example by adding the second web-method with following request:

POST /soap/getOrigin HTTP/1.1
Host: localhost:1882
Content-Type: text/xml
Cache-Control: no-cache

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://example.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:originRequest>
         <id>18</id>
      </ser:originRequest>
   </soapenv:Body>
</soapenv:Envelope>

So, I agree that specific request info is containing in body: originRequest and personRequest. But if I have these two methods in my application (@PayloadRoot(namespace = NAMESPACE_URI, localPart = "originRequest") and @PayloadRoot(namespace = NAMESPACE_URI, localPart = "personRequest"), I have incorrect metrics in Prometheus after two requests: both of them are handled by one metric:

http_server_requests_seconds_count{exception="None",method="POST",outcome="SUCCESS",status="200",uri="UNKNOWN",} 2.0

And I wanna have something like this:

http_server_requests_seconds_count{exception="None",method="POST",outcome="SUCCESS",status="200",uri="soap/getPerson",} 1.0
http_server_requests_seconds_count{exception="None",method="POST",outcome="SUCCESS",status="200",uri="soap/getOrigin",} 1.0

Therefore my point is that I want to have different metrics for my different SOAP-methods, like @RestController allows to do for different URLs.

Bun in fact, our clients request service by one URL, even service has a lot of methods. So the URI in prometheus will be the same in this case anyway:)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 6, 2018
@wilkinsona
Copy link
Member

Thanks for the additional information. To implement that we'd need something (perhaps a request attribute) that provides a URI known to have low cardinality so it's suitable for use as a tag's value. AFAIK, Spring Web Services doesn't provide anything like that at the moment. Let's see what @gregturn says.

@wilkinsona wilkinsona added status: blocked An issue that's blocked on an external project change type: enhancement A general enhancement and removed status: blocked An issue that's blocked on an external project change status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Dec 6, 2018
@shark300
Copy link

shark300 commented Sep 3, 2019

@wilkinsona what's the plan?

@wilkinsona
Copy link
Member

@shark300 There isn't much of a plan at the moment as we're blocked until we get some input from @gregturn, unfortunately.

@gregturn
Copy link
Contributor

gregturn commented Sep 3, 2019

@wilkinsona is correct. Spring WS does not (yet) have support for Micrometer.

I haven't had time to pursue that feature addition, but can try to move it up in priority.

@shark300
Copy link

shark300 commented Sep 3, 2019

Thank you everyone, we will keep in touch regarding to this issue :)

@philwebb philwebb added this to the General Backlog milestone Sep 3, 2019
@r00ta
Copy link

r00ta commented Feb 28, 2020

Hi, Any update on this? Is there any workaround to add the URI to the labels atm?
Btw It would be nice to have the possibility to specify some arguments in the @Timed annotation, isnt't?

@wilkinsona
Copy link
Member

@r00ta As indicated by the issue's labels, I'm afraid this issue is still blocked from Spring Boot's perspective. @gregturn may have an update from the Spring WS side of things.

@shark300
Copy link

shark300 commented Feb 28, 2020

As a workaround you can use CXF as a SOAP handler because I've opened a PR for CXF starter yet:
apache/cxf#642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked An issue that's blocked on an external project change type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

7 participants