Get size request and response - Apigee Private Cloud

Hello,

We need to study the behaviour of our platform (Apigee Private Cloud 4.50 and 4.51 soon) depending on the size of the request and response bodies. 

All that we have seen is about the content-length headers but it is not enough for us because those headers are empty in a multiple requests.

We are considering to use one javascript policy to obtain the size of the bodies as follows:

  • request.content.length
  • response.content.length

We want to ask you if this is the best way to develop this, because we have a lot of requests and the delay that this new functionality might cause its our main concern.

Considerer that many bodies will be sizes of several megabytes.

Thank you in advance. 

Best regards.

0 4 187
4 REPLIES 4

Why do you want to know the request/response sizes, and what do you intend to do with it? 

If this is for an analytics use case, note that payload metrics are already captured in analytics - refer to https://docs.apigee.com/api-platform/analytics/analytics-reference

Hello @dknezic,

Thanks for your reply.

We need to know the request and response sizes because we have othere applications for monitoring and traceability shared with other teams and those teams are not allowed to enter in our Apigee platform.

We've found records in the "apigee.analytics..{ORG}.{ENV}.fact" table of PostgreSQL with "request_size" and "response_size" but, it is possible to obtain this info at requests runtime?

As I said in the previous comment, we are concerned about the behaviour of the platform when getting the variables "request/response.content" and calculate sizes of several megabytes.

Thank you.

Best regards.

What is your proxy logging mechanism? Just enable additional headers and push it to your log framework via post flow.

Just download sample proxy trace & go thru to better understand on the variables(sometimes it helps)..

eg:

var reqMessageSize = context.getVariable("request.header.Content-Length");
var tgtMessageSize = context.getVariable("response.header.Content-Length");

Thankyou.

We cannot use the content-length headers because they are empty in multiple requests.

Therefore, we need to find another way to show this information in the logs.

Our question is, is there a flow variable to obtain this value or should we always calculate it?

We don't like the solution of using "request/response.content.length" because in large files it adds a lot of delay in the request. Do you know if there is another way to get this data?

Thank you in advance.