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

Support HTTP request/response size #880

Open
dipindas opened this issue Sep 28, 2018 · 12 comments
Open

Support HTTP request/response size #880

dipindas opened this issue Sep 28, 2018 · 12 comments
Labels
enhancement A general enhancement help wanted An issue that a contributor can help us with spring-boot change Change is needed in Spring Boot for this issue
Milestone

Comments

@dipindas
Copy link

Please add support to get http response size as a metric value

@jkschneider
Copy link
Contributor

jkschneider commented Sep 29, 2018

Thanks. Surprised we didn't think of that earlier. Will do it with a DistributionSummary so you can best understand the distribution of response sizes over time.

Just requires a change to WebMvcMetricsFilter, et al and making the corresponding change in Spring Boot 2 and other web frameworks.

@jkschneider jkschneider added the spring-boot change Change is needed in Spring Boot for this issue label Sep 29, 2018
@jkschneider jkschneider added this to the 1.1.0-rc.1 milestone Sep 29, 2018
@mweirauch
Copy link
Contributor

Just out of curiosity, would this include body-only-size or include the headers as well?

@shakuzen
Copy link
Member

shakuzen commented Oct 2, 2018

@mweirauch I think we should do both body and headers (with a tag?) as much as possible. Also, a separate metric for request and response sizes would be potentially useful.
both?

@mweirauch
Copy link
Contributor

Sounds good.
Would we be differentiating between server and client side instrumentation? Guess so.
So in analogy to http.server.requests and http.client.requests:
http.server.request.size and http.client.request.size? (Don't pin me on the naming.)

@izeye
Copy link
Contributor

izeye commented Oct 2, 2018

http.server.request.size and http.client.request.size? (Don't pin me on the naming.)

@mweirauch I guess you meant http.server.response.size and http.client.response.size?

@mweirauch
Copy link
Contributor

Eek, things go wrong when doing stuff in between. What I meant was ...
http.server.[request,response].size for server (webmvc,jersey,webflux) instrumentation
and
http.client.[request,response].size for client (RestTemplate, okhttp?,...) instrumentation

@jkschneider jkschneider modified the milestones: 1.1.0-rc.1, 1.2.0 Oct 12, 2018
@jkschneider jkschneider modified the milestones: 1.2.0, 1.x Oct 26, 2018
@shakuzen shakuzen added enhancement A general enhancement help wanted An issue that a contributor can help us with labels Apr 10, 2019
@fzyzcjy
Copy link

fzyzcjy commented Feb 1, 2021

Hi is there any updates (after 2 years)?

@drriguz
Copy link

drriguz commented Jan 25, 2022

Hi is there any updates (after 2 years)?

Hi is there any updates (after 3 years)?

@shakuzen shakuzen modified the milestones: 1.x, 1.11 backlog Jan 31, 2023
@shakuzen shakuzen changed the title Support to get http response size by micrometer Support HTTP request/response size Feb 2, 2023
@MayankManas1
Copy link

hi, is there any updates (after 4 years)?

@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Mar 7, 2023

There was:

shakuzen modified the milestones: 1.x, 1.11 backlog on Jan 31

It's not a guarantee that it will make it to 1.11 but issues like this (help-wanted label) are good for contributions if anyone wants to file a PR.

@shakuzen shakuzen modified the milestones: 1.11 backlog, 1.12 backlog May 9, 2023
@babbarimam
Copy link

Hi @shakuzen ,
can you please confirm when and in which version we can expect the http response size metrics?
Thanks

@bclozel
Copy link
Contributor

bclozel commented Jul 7, 2023

From a Framework instrumentation perspective:

An easy way to instrument this would be to read the Content-Length HTTP header - unfortunately a lot of requests and responses use Transfer-Encoding: chunked and the only way to know the actual size is to wrap the request/responses and count the bytes as they're being read. Because this can happen with blocking and non-blocking I/O at the Servlet level, this can be quite challenging to implement and could cause a significant performance drop.

Also, even if this first problem is solved, the message size at the web Framework level is not the same as the actual message size on the network. Servers and Servlet containers in general support message compression and perform this task on-the-fly. This means that this metric instrumentation would need to happen at the server level, not at the web framework level. This part is highlighted in the OTel semantic conventions as well and the metric itself is optional.

To summarize, I think that mentioning WebMvcMetricsFilter is misleading here as the instrumentation must happen at the level of the HTTP library (server or client). For example, developers would need to use a binder to instrument Tomcat, not rely on the instrumentation done at the Spring Framework/Spring Boot level.

I think the best way to make progress on this is to review the available binders for HTTP servers and clients, and figure out if this type of instrumentation is possible in an efficient manner for each.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement help wanted An issue that a contributor can help us with spring-boot change Change is needed in Spring Boot for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.