feat: add fallback support for request and response size#272
feat: add fallback support for request and response size#272kotharironak merged 11 commits intomainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #272 +/- ##
============================================
+ Coverage 80.20% 80.45% +0.24%
- Complexity 1181 1209 +28
============================================
Files 106 106
Lines 4588 4662 +74
Branches 424 436 +12
============================================
+ Hits 3680 3751 +71
- Misses 709 710 +1
- Partials 199 201 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Also added support for tags,
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| String requestBody = attributeValueMap.get(RPC_REQUEST_BODY.getValue()).getValue(); | ||
| return Optional.of(requestBody.length()); | ||
| } | ||
| if (attributeValueMap.get(RawSpanConstants.getValue(ENVOY_REQUEST_SIZE)) != null) { |
There was a problem hiding this comment.
nit: There are repetitive RawSpanContants.getValue() calls. Can these be extracted out as static variables.
|
|
||
| private static boolean isGrpcResponseBodyTruncated( | ||
| Map<String, AttributeValue> attributeValueMap) { | ||
| if (attributeValueMap.get(RawSpanConstants.getValue(GRPC_RESPONSE_BODY_TRUNCATED)) != null) { |
There was a problem hiding this comment.
Extract attributeValueMap.get(RawSpanConstants.getValue(GRPC_RESPONSE_BODY_TRUNCATED) out and reuse below
| } | ||
|
|
||
| private static boolean isRpcResponseBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
| if (attributeValueMap.get(RPC_RESPONSE_BODY_TRUNCATED.getValue()) != null) { |
There was a problem hiding this comment.
Same comment as above
This comment has been minimized.
This comment has been minimized.
| if (!requestSize.isEmpty()) return requestSize.map(Integer::parseInt); | ||
|
|
||
| if (SpanAttributeUtils.getBooleanAttribute( | ||
| event, RawSpanConstants.getValue(HTTP_REQUEST_BODY_TRUNCATED))) { |
There was a problem hiding this comment.
RawSpanConstants.getValue(HTTP_REQUEST_BODY_TRUNCATED can move to static variable
| if (!responseSize.isEmpty()) return responseSize.map(Integer::parseInt); | ||
|
|
||
| if (SpanAttributeUtils.getBooleanAttribute( | ||
| event, RawSpanConstants.getValue(HTTP_RESPONSE_BODY_TRUNCATED))) { |
There was a problem hiding this comment.
move to static variable
| } | ||
|
|
||
| private static boolean isGrpcRequestBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
| if (attributeValueMap.get(GRPC_REQUEST_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
If the GRPC_REQUEST_BODY_TRUNCATED_ATTR attribute is present in the map, then you end up getting it twice - once for the null check and then for the Boolean parsing below. Please fix.
There was a problem hiding this comment.
Most parts of the file were written in a similar manner so had followed the pattern. But, given this is a part of the ingestion pipeline, a small constant time boost compare to stack push/pop operation vs calc hashing twice would be helpful with respect to traffic. Changing this code, and created an issue for going over all the utilities for the same.
Issue for this : hypertrace/hypertrace#316
| } | ||
|
|
||
| private static boolean isRpcRequestBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
| if (attributeValueMap.get(RPC_REQUEST_BODY_TRUNCATED_ATTR) != null) { |
| String requestBody = attributeValueMap.get(RPC_REQUEST_BODY.getValue()).getValue(); | ||
| return Optional.of(requestBody.length()); | ||
| } | ||
| if (attributeValueMap.get(ENVOY_REQUEST_SIZE_ATTR) != null) { |
There was a problem hiding this comment.
optimize the multiple get from the map here too
| if (attributeValueMap.get(ENVOY_REQUEST_SIZE_ATTR) != null) { | ||
| return Optional.of( | ||
| Integer.parseInt(attributeValueMap.get(ENVOY_REQUEST_SIZE_ATTR).getValue())); | ||
| } else if (isRpcSystemGrpc(attributeValueMap) |
There was a problem hiding this comment.
optimize the multiple get from the map here too
| return Optional.of( | ||
| Integer.parseInt( | ||
| attributeValueMap.get(RPC_REQUEST_METADATA_CONTENT_LENGTH_ATTR).getValue())); | ||
| } else if (attributeValueMap.get(GRPC_REQUEST_BODY_ATTR) != null |
There was a problem hiding this comment.
optimize the multiple get from the map here too
| String requestBody = attributeValueMap.get(GRPC_REQUEST_BODY_ATTR).getValue(); | ||
| return Optional.of(requestBody.length()); | ||
| } else if (isRpcSystemGrpc(attributeValueMap) | ||
| && attributeValueMap.get(RPC_REQUEST_BODY_ATTR) != null |
There was a problem hiding this comment.
optimize the multiple get from the map here too
|
|
||
| private static boolean isGrpcResponseBodyTruncated( | ||
| Map<String, AttributeValue> attributeValueMap) { | ||
| if (attributeValueMap.get(GRPC_RESPONSE_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
optimize the multiple get from the map here too
| } | ||
|
|
||
| private static boolean isRpcResponseBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
| if (attributeValueMap.get(RPC_RESPONSE_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
optimize the multiple get from the map here too
|
@avinashkolluru Created the issue of multiple read from the map here for handling throughout file - #272 (comment), have the address for them for the exiting PR. |
Description
Currently, there are following three attributes consider for calculating response size
response_sizehttp.response.sizehttp.response_content_lengthAs part of this PR, we will be adding fallback to calculate using the content of
http.response.bodyif above are abset.The same will be applied to request size calculation.
request_sizehttp.request.sizehttp.request_content_lengthSo, the fallback will be the size of
http.request.bodyattributeTesting
Checklist: