Skip to content

gRPC support request/response size#11833

Closed
crossoverJie wants to merge 28 commits intoopen-telemetry:mainfrom
crossoverJie:grpc-req-res-size
Closed

gRPC support request/response size#11833
crossoverJie wants to merge 28 commits intoopen-telemetry:mainfrom
crossoverJie:grpc-req-res-size

Conversation

@crossoverJie
Copy link
Copy Markdown
Member

@crossoverJie crossoverJie requested a review from a team July 16, 2024 09:46
@crossoverJie crossoverJie marked this pull request as draft July 18, 2024 01:41
Comment thread instrumentation/grpc-1.6/javaagent/build.gradle.kts Outdated
@crossoverJie crossoverJie marked this pull request as ready for review July 20, 2024 14:44
@crossoverJie
Copy link
Copy Markdown
Member Author

@trask @laurit PTAL, thanks.

@crossoverJie crossoverJie requested a review from steverao July 22, 2024 14:36
Comment on lines +28 to +42
default int getClientRequestSize(REQUEST request) {
return 0;
}

default int getClientResponseSize(REQUEST request) {
return 0;
}

default int getServerRequestSize(REQUEST request) {
return 0;
}

default int getServerResponseSize(REQUEST request) {
return 0;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type for these should be Long, and these should return null by default. We need to consider whether this should be split into separate client/server getters similarly to what we do for http client/server. Would it make sense to introduce a response parameter too? Or perhaps just have getRequestSize and getResponseSize in the getter, we already have separate extractors for client/server these could be used to set the correct attribute.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for your suggestion, Done.


Long rpcServerRequestBodySize =
RpcMessageBodySizeUtil.getRpcServerRequestBodySize(endAttributes, state.startAttributes());
if (rpcServerRequestBodySize != null && rpcServerRequestBodySize > 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> 0 condition is weird. I think you can get rid of it by changing the type in getter from int -> Long so you can distinguish when getter does not implement this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ServerAttributes.SERVER_PORT));
}

static void applyClientRequestSizeAdvice(LongHistogramBuilder builder) {
Copy link
Copy Markdown
Contributor

@laurit laurit Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you are always going to use the same set of attributes you could make all these delegate to a common method or extract the attributes list to a variable

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +33 to +40
private static final AttributeKey<Long> RPC_CLIENT_REQUEST_BODY_SIZE =
AttributeKey.longKey("rpc.client.request.body.size");
private static final AttributeKey<Long> RPC_CLIENT_RESPONSE_BODY_SIZE =
AttributeKey.longKey("rpc.client.response.body.size");
private static final AttributeKey<Long> RPC_SERVER_REQUEST_BODY_SIZE =
AttributeKey.longKey("rpc.server.request.body.size");
private static final AttributeKey<Long> RPC_SERVER_RESPONSE_BODY_SIZE =
AttributeKey.longKey("rpc.server.response.body.size");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in tests you should use RpcIncubatingAttributes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These attributes do not currently exist in RpcIncubatingAttributes, Maybe we should define them in semantic-conventions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you should try getting these included in the semantic attributes

Comment thread instrumentation/grpc-1.6/javaagent/build.gradle.kts
@github-actions
Copy link
Copy Markdown
Contributor

This PR has been labeled as stale due to lack of activity. It will be automatically closed if there is no further activity over the next 14 days.

@github-actions github-actions Bot added the stale label Sep 29, 2025
@laurit
Copy link
Copy Markdown
Contributor

laurit commented Sep 30, 2025

Superseded by #14342

@laurit laurit closed this Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Response/Request Size GRPC Metrics Instrumentation

3 participants