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

Document that http.client.requests measure the entire HTTP exchange #34201

Closed
mateusz-nalepa opened this issue Jan 6, 2025 · 2 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: documentation A documentation task
Milestone

Comments

@mateusz-nalepa
Copy link

mateusz-nalepa commented Jan 6, 2025

Hello! 👋

Context

https://docs.spring.io/spring-boot/reference/actuator/metrics.html#actuator.metrics.supported.http-clients
By looking at the description of client metric, I wouldn't say, that http.client.requests metric includes things like eq: waiting for connection in connection pool.
Sometimes i see Spikes for dashboards with this metric and i would like to know, that those SPIKE's may be visible due to requests waiting in queue or something else.

In order to have only request time, I need to measure request time on RequestFactory level.

Example

Spring Boot Version - 3.4.1

I've prepared an small example, where I'm executing 4 requests with connection pool size equal to 2 and response from wiremock stub equal to 50ms. Here's the code: https://github.com/mateusz-nalepa/communication-errors/blob/main/src/test/kotlin/com/mateusz/nalepa/communicationerrors/timeout/queue/ConnectionRequestTimeoutWaitingInQueue.kt#L107

Here's the results:

Single request took: 52 ms
http.client metric duration value: 53.469458ms
Single request took: 54 ms
http.client metric duration value: 54.166459ms
Single request took: 54 ms
Single request took: 53 ms
http.client metric duration value: 108.194083ms
http.client metric duration value: 108.211042ms

So as you can see, those last two request contains of:

  • request itself
  • waiting in queue

Proposal

I would like to add some tip for documentation like:

This metric is not applied on the particular Request Factory. 
So value of this metric is not always equal to request itself. 
As a part of this metric there can be for example: waiting for connection from connection pool.

Question

What do you think?
Please let me know! 😄

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 6, 2025
@bclozel bclozel transferred this issue from spring-projects/spring-boot Jan 6, 2025
@bclozel
Copy link
Member

bclozel commented Jan 6, 2025

The current documentation for http.client.requests says "Time spent for HTTP client exchanges". I believe this is an accurate description as this involves the entire exchange: from connection establishment up to body deserialization. Since the instrumentation is done at the WebClient/RestClient/RestTemplate level, I assume that it's natural to measure the time spent within method calls on those types. Depending on the HTTP library being used, there might not be a connection pool at all.

We could add a short sentence here stating that. Would this work for you?

@bclozel bclozel self-assigned this Jan 6, 2025
@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue type: documentation A documentation task theme: observability An issue related to observability and tracing labels Jan 6, 2025
@mateusz-nalepa
Copy link
Author

mateusz-nalepa commented Jan 6, 2025

The current documentation for http.client.requests says "Time spent for HTTP client exchanges".

Yup, it's true. But what, if you don't know what the exchange really is?
Few years ago I've watched a brilliant presentation GeeCON 2017: Adam Dubiel - HTTP clients: silent heroes of distributed systems which explained this topic. So i would say, that it's easier to understand numbers, when you have an idea how things works under the hood.

We could add a short sentence here stating that. Would this work for you?

Yes!

@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 Jan 6, 2025
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Jan 8, 2025
@bclozel bclozel added this to the 6.2.2 milestone Jan 8, 2025
@bclozel bclozel changed the title [DOCUMENTATION TIP] http.client.requests - Add tip Document that http.client.requests measure the entire HTTP exchange Jan 8, 2025
@bclozel bclozel closed this as completed in 9173e13 Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants