KEMBAR78
feat(bigquery): Add OpenTelemetry support to BQ rpcs by whuffman36 · Pull Request #3860 · googleapis/java-bigquery · GitHub
Skip to content

Conversation

whuffman36
Copy link
Contributor

No description provided.

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigquery Issues related to the googleapis/java-bigquery API. labels Jun 24, 2025
}
Table tableResponse = bqPatchRequest.execute();
if (patchTable != null) {
patchTable.setAttribute("bq.rpc.response", tableResponse.toPrettyString());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You guys mentioned before wanting to capture the response, but it is pretty verbose in the output. Is there anything specific from the responses that you think is most important?

@whuffman36 whuffman36 self-assigned this Jun 24, 2025
@whuffman36 whuffman36 marked this pull request as ready for review June 24, 2025 16:54
@whuffman36 whuffman36 requested a review from a team as a code owner June 24, 2025 16:54
@whuffman36
Copy link
Contributor Author

A lot of useful data, such as jobId or location, could be captured here in the rpc layer, but it would just be doubling up the attributes that were already captured in the interface layer. What are your thoughts on keeping the rpc layer scoped to unique "rpc relevant" attributes vs capturing some values in both layers?

.setAttribute("bq.rpc.page_token", datasetsListRequest.getPageToken())
.setAttribute("bq.rpc.access_token", datasetsListRequest.getAccessToken())
.setAttribute("bq.rpc.oauth_token", datasetsListRequest.getOauthToken())
.setAttribute("bq.rpc.request_method", datasetsListRequest.getRequestMethod())
Copy link
Contributor

Choose a reason for hiding this comment

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

why is there both a method and request_method in here? That seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed that it's not very useful, but request method refers to the http method used (GET, POST, PATCH, etc). You and Phong both mentioned this field, so I removed it.

}
Table tableResponse = bqCreateRequest.execute();
if (createTable != null) {
createTable.setAttribute("bq.rpc.response", tableResponse.toPrettyString());
Copy link
Contributor

Choose a reason for hiding this comment

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

My main worry about logging the responses is going to be large responses. In general, should we enforce a configurable limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a configurable limit for attribute sizes (default is unlimited), but this is toggled at the SDK level through an environment variable or system property. In my opinion, this is something that should be left up to the user in case they want to have giant attributes for their own tracing or metrics.

It's probably better to just filter for important fields in the response, like id and nextPageToken like Phong suggested

@whuffman36
Copy link
Contributor Author

I've updated the response attributes to only contain the response id and the nextPageToken field for the list RPCs to limit the attribute size. I also added the JobStatus.state attribute for the relevant spans.

The oauth token, access token, and request_method attributes have all been removed.

Copy link
Contributor

@PhongChuong PhongChuong left a comment

Choose a reason for hiding this comment

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

Thanks for the fix.
Approved pending the response attribute inconsistency.

@whuffman36 whuffman36 merged commit e2d23c1 into main Jun 26, 2025
23 checks passed
@whuffman36 whuffman36 deleted the rpc-otel branch June 26, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/java-bigquery API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants