How to get and filter transactions based on response header Content-Length

Essentially the topic.
We would like to search for responses based on size of the responses.
From what I understand, this header is not logged by default. Even if they would we would have to add them to index like Configure Elasticsearch index template loading | APM Server Reference [7.15] | Elastic, right?
Thanks

The apm java agent should capture headers by default.

What HTTP library (client/server) of which you want to see the headers are you using?

Yes headers are captured, but not this one. This is what we see


we are using spring mvc and camel over spring.

The headers you provided show that Transfer-Encoding is chunked, meaning that your request doesn't have a Content-Length header: the data is streamed and the total size is not known at the point in time the headers are sent.

I think the only option you have is to modify your code and add the content length to your transaction as a label. I'd recommend using the OpenTelemetry API.

oh. thanks

OK the "issue" seems to be that json converter is streaming the response. I am curious, if it would be possible for agent to hook and wrap servlet output stream, that would count bytes sent.
IMHO having information about the size of request/response is about the same as having info about the duration.

it would be possible agent to hook and wrap servlet output stream

It definitiely is possible, however it is a dangerous thing to do: There are many application out there, which rely on having a specific subtype of OutputStream and cast them accordingly. If the agent now wraps the output stream, this would suddenly break the application.

This is also one of the main reasons why we don't support capturing request and response content for the server requests being handled by the application.

If you want to, you could however try to implement this using a custom plugin.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.