Skip to content

chore: refactor all opentelemetry span logic for RPC calls into generic executeWithSpan function#12066

Closed
ldetmer wants to merge 3 commits intomain-backupfrom
refactor-existing-spans
Closed

chore: refactor all opentelemetry span logic for RPC calls into generic executeWithSpan function#12066
ldetmer wants to merge 3 commits intomain-backupfrom
refactor-existing-spans

Conversation

@ldetmer
Copy link
Contributor

@ldetmer ldetmer commented Mar 12, 2026

This is to setup the ability to add new attributes to existing tracing span for the observability project. This is no-op functional change for the current code, but achieves the following:

  1. Moves all tracing logic (creation, attribute setting, closing) into new executeWithSpan generic function. Is useful for potential future changes.
  2. Adds the functionality to make each client span the current span. This does not have any affect on the traces themselves (see comparison below), but it does allow for us to retrieve this span in an HTTP interceptor and append additional attributes. See design: go/sdk:java-bigquery-observability. Without this change the current span returned is the parent span.

Example trace before change

Example trace after change

@ldetmer ldetmer changed the title chore: refactor all opentelemetry span for RPC calls in one place chore: refactor all opentelemetry span logic for RPC calls into generic executeWithSpan function Mar 12, 2026
try (Scope scope = span.makeCurrent()) {
return operation.execute(span);
} finally {
span.end();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to add a test for an RPC failure to verify this behavior?

ldetmer added a commit that referenced this pull request Mar 13, 2026
Add full unit test coverage for HttpBigQueryRpc for easy validation of
refactor changes for the observability project [see fast follow
PR](#12066).
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 13, 2026
Add full unit test coverage for HttpBigQueryRpc for easy validation of
refactor changes for the observability project [see fast follow
PR](googleapis#12066).
@suztomo
Copy link
Member

suztomo commented Mar 13, 2026

We had to rewrite the history of this repository (See "SDK Java" chat for details). The pending pull requests require some actions:

  • If your pull requests do not have merge commits from the main branch, git rebase --onto origin/main should work.
  • If git rebase does not work, please re-create a new branch from oriign/main. Use git read-tree --reset -u to restore the source tree from your old branch. Create a new pull request from the new branch.

@chingor13 chingor13 changed the base branch from main to main-backup March 13, 2026 16:35
@ldetmer
Copy link
Contributor Author

ldetmer commented Mar 13, 2026

i had too many conflicts will open new PR

@ldetmer ldetmer closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants