-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: add fallback support for request and response size #272
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.
...src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java
Show resolved
Hide resolved
...src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java
Show resolved
Hide resolved
...src/main/java/org/hypertrace/semantic/convention/utils/http/HttpSemanticConventionUtils.java
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
...er/src/main/java/org/hypertrace/core/spannormalizer/fieldgenerators/HttpFieldsGenerator.java
Show resolved
Hide resolved
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: There are repetitive RawSpanContants.getValue() calls. Can these be extracted out as static variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
return Optional.empty(); | ||
} | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract attributeValueMap.get(RawSpanConstants.getValue(GRPC_RESPONSE_BODY_TRUNCATED)
out and reuse below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
} | ||
|
||
private static boolean isRpcResponseBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
if (attributeValueMap.get(RPC_RESPONSE_BODY_TRUNCATED.getValue()) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to static variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -269,55 +297,92 @@ public static String getGrpcErrorMsg(Event event) { | |||
return Optional.empty(); | |||
} | |||
|
|||
private static boolean isGrpcRequestBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | |||
if (attributeValueMap.get(GRPC_REQUEST_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
|
||
private static boolean isRpcRequestBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
if (attributeValueMap.get(RPC_REQUEST_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize the multiple get from the map here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize the multiple get from the map here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize the multiple get from the map here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize the multiple get from the map here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return Optional.empty(); | ||
} | ||
|
||
private static boolean isGrpcResponseBodyTruncated( | ||
Map<String, AttributeValue> attributeValueMap) { | ||
if (attributeValueMap.get(GRPC_RESPONSE_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize the multiple get from the map here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
|
||
private static boolean isRpcResponseBodyTruncated(Map<String, AttributeValue> attributeValueMap) { | ||
if (attributeValueMap.get(RPC_RESPONSE_BODY_TRUNCATED_ATTR) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize the multiple get from the map here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@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. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Currently, there are following three attributes consider for calculating response size
response_size
http.response.size
http.response_content_length
As part of this PR, we will be adding fallback to calculate using the content of
http.response.body
if above are abset.The same will be applied to request size calculation.
request_size
http.request.size
http.request_content_length
So, the fallback will be the size of
http.request.body
attributeTesting
Checklist: