Skip to content

impl(o11y): add operation name support to Poller interface#5694

Open
haphungw wants to merge 1 commit into
googleapis:mainfrom
haphungw:stacked-pr-2-rust-lro-operation-name-interface
Open

impl(o11y): add operation name support to Poller interface#5694
haphungw wants to merge 1 commit into
googleapis:mainfrom
haphungw:stacked-pr-2-rust-lro-operation-name-interface

Conversation

@haphungw
Copy link
Copy Markdown
Contributor

Allow tracing decorators to dynamically query LRO operation IDs from underlying poller for telemetry recording.

Because PollerImpl is encapsulated as a generic inside the telemetry decorator, we can't do direct field access (like self.inner.operation) on the generic type. Declaring this standard method on the Poller trait supports LRO tracing attribute propagation without contaminating public structs.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an operation_name method to the Poller trait and its various implementations to allow retrieving the name of a long-running operation. The reviewer suggests changing the return type from Option<String> to Option<&str> to avoid unnecessary allocations and clones, making the API more idiomatic and efficient. Additionally, feedback was provided to use as_deref() in implementations and to update test assertions to use string literals for better independence.

Comment thread src/lro/src/lib.rs Outdated
Comment thread src/lro/src/internal/aip151.rs Outdated
Comment thread src/lro/src/internal/aip151.rs Outdated
Comment thread src/lro/src/internal/aip151.rs Outdated
Comment thread src/lro/src/internal/aip151.rs Outdated
Comment thread src/lro/src/internal/either.rs Outdated
Comment thread src/lro/src/internal/either.rs Outdated
Comment thread src/lro/src/internal/either.rs Outdated
Comment thread src/lro/src/internal/ext.rs Outdated
Comment thread src/lro/src/internal/tracing.rs Outdated
@haphungw haphungw force-pushed the stacked-pr-2-rust-lro-operation-name-interface branch from 1b013bc to 201e963 Compare May 19, 2026 21:02
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 60.46512% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.88%. Comparing base (6e7650c) to head (201e963).

Files with missing lines Patch % Lines
src/lro/src/internal/aip151.rs 45.45% 6 Missing ⚠️
src/lro/src/internal/discovery.rs 77.77% 6 Missing ⚠️
src/lro/src/internal/either.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5694      +/-   ##
==========================================
- Coverage   97.91%   97.88%   -0.03%     
==========================================
  Files         226      226              
  Lines       55347    55390      +43     
==========================================
+ Hits        54191    54219      +28     
- Misses       1156     1171      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haphungw haphungw marked this pull request as ready for review May 19, 2026 21:12
@haphungw haphungw requested a review from a team as a code owner May 19, 2026 21:12
Comment thread src/lro/src/lib.rs
Comment on lines +152 to +153
/// Returns the name of the operation, if known.
fn operation_name(&self) -> Option<&str>;
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.

This is fine. It is a new public API, but not a big deal. But I just realized that backoff() is also public, and I wonder if we should have not made it so...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I found an alternative to avoid touching the public API: #5695.

Instead of adding operation_name() to query the inner poller, Tracing<P>::poll now enters the T2 span scope before delegating the poll call. The T2 span is now active in the thread context, and the pollers can record the operation name directly onto it using tracing::Span::current().record().

If you think this works, I can go ahead and close this PR.

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.

2 participants