Skip to content

impl(o11y): record error.type attribute on LRO span#5895

Open
haphungw wants to merge 1 commit into
googleapis:mainfrom
haphungw:fix-lro-tracing-error-type-telemetry
Open

impl(o11y): record error.type attribute on LRO span#5895
haphungw wants to merge 1 commit into
googleapis:mainfrom
haphungw:fix-lro-tracing-error-type-telemetry

Conversation

@haphungw

Copy link
Copy Markdown
Contributor

Add error.type attribute to the LRO (T2) span and populate it from the status code if the long-running operation fails with a status code. This allows observability tools to track error rates by error type for long-running operations.

This lack of T2 error type recording is surfaced in the error.type assertions requested for LRO tracing integration tests (#5886).

@haphungw haphungw marked this pull request as ready for review June 16, 2026 21:11
@haphungw haphungw requested a review from a team as a code owner June 16, 2026 21:11

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

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.

Code Review

This pull request introduces the error.type attribute to tracing spans when recording errors in the LRO module, and refactors several test assertions to use contains_key instead of checking if get returns None. Feedback on the changes suggests providing a fallback value (such as "generic") for error.type when no specific gRPC status code is available, ensuring compliance with OpenTelemetry semantic conventions for error spans.

Comment thread src/lro/src/internal/tracing.rs Outdated
@haphungw haphungw force-pushed the fix-lro-tracing-error-type-telemetry branch 2 times, most recently from d2f00bc to 8911bc6 Compare June 16, 2026 21:20
Comment thread src/lro/src/internal/tracing.rs Outdated
pub fn record_error(&self, err: &crate::Error) {
self.span.record("otel.status_code", "ERROR");
self.span.record("otel.status_description", err.to_string());
if let Some(status) = err.status() {

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.

Can we use

without too much modification?

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'd have to modify gaxi to expose ErrorType

Comment thread src/lro/src/internal/tracing.rs Outdated
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.90%. Comparing base (5102ca3) to head (954c44e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5895   +/-   ##
=======================================
  Coverage   97.90%   97.90%           
=======================================
  Files         233      233           
  Lines       59211    59211           
=======================================
  Hits        57968    57968           
  Misses       1243     1243           

☔ View full report in Codecov by Harness.
📢 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 force-pushed the fix-lro-tracing-error-type-telemetry branch from 8911bc6 to aed4044 Compare June 16, 2026 21:36
@haphungw haphungw requested a review from westarle June 16, 2026 22:00
@haphungw haphungw force-pushed the fix-lro-tracing-error-type-telemetry branch from aed4044 to 2e9cec5 Compare June 16, 2026 22:06
@haphungw haphungw changed the title impl(o11y): record error.type attribute on LRO Wait span impl(o11y): record error.type attribute on LRO span Jun 16, 2026

@westarle westarle left a comment

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.

I think it looks good, but I'd like @dbolduc or someone familiar with Rust to comment on any downside to exposing the errors module pub in gaxi and adding the dependency here.

Comment thread src/lro/src/internal/tracing.rs Outdated
Comment thread src/lro/src/internal/tracing.rs Outdated
@haphungw haphungw force-pushed the fix-lro-tracing-error-type-telemetry branch from 2e9cec5 to f2554de Compare June 16, 2026 22:23

@dbolduc dbolduc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am fine with exposing something from gaxi, but in a vacuum, I would minimize the surface.

Will any other layer need to know what is a strongly-typed ErrorType? Or do they just need to know how to encode it as an attribute?

Comment thread src/lro/Cargo.toml Outdated
Comment thread src/gax-internal/src/observability.rs Outdated
Comment thread src/gax-internal/src/observability/errors.rs
Comment thread src/lro/src/internal/tracing.rs Outdated
Comment thread src/gax-internal/src/observability/errors.rs Outdated
@haphungw

Copy link
Copy Markdown
Contributor Author

@dbolduc I added this refactoring PR #5908 to fix those problems in gaxi.

haphungw added a commit that referenced this pull request Jun 17, 2026
…ommon feature (#5908)

Refactor `gaxi` errors tracing observability module to minimize the
public API surface and optimize feature gating for downstream usage.

This is a prerequisite for adding `error.type` span attributes recording
to the LRO span (#5895), ensuring `google-cloud-lro` can fetch error
tracing categories without bloating its dependency footprint.
@haphungw haphungw force-pushed the fix-lro-tracing-error-type-telemetry branch from f2554de to 954c44e Compare June 17, 2026 20:28
@haphungw haphungw requested a review from dbolduc June 17, 2026 20:29
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