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.

Comment From: wilkinsona

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

Comment From: SorokinStanislav

@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:)

Comment From: wilkinsona

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.

Comment From: shark300

@wilkinsona what's the plan?

Comment From: wilkinsona

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

Comment From: gregturn

@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.

Comment From: shark300

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

Comment From: r00ta

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?

Comment From: wilkinsona

@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.

Comment From: shark300

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