Skip to content

refactor(o11y): minimize internal API surface and gate errors under common feature#5908

Merged
haphungw merged 3 commits into
googleapis:mainfrom
haphungw:refactor-observability-errors
Jun 17, 2026
Merged

refactor(o11y): minimize internal API surface and gate errors under common feature#5908
haphungw merged 3 commits into
googleapis:mainfrom
haphungw:refactor-observability-errors

Conversation

@haphungw

Copy link
Copy Markdown
Contributor

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.

…ommon feature

Hide ErrorType enum inside the gax-internal crate and only expose a
public error_type helper function to extract error.type. This minimizes
the public API surface of the crate.

Gate the errors module under _internal-common feature to avoid including
unnecessary gRPC/HTTP components in downstream dependencies of crates (like
google-cloud-lro) that only need basic tracing capabilities.

Implement std::fmt::Display for ErrorType to make it more idiomatic and
efficient by returning &str instead of String allocations.

@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 refactors the observability error handling in gax-internal by implementing std::fmt::Display for ErrorType and replacing the .as_str() method with .to_string() across various tracing and logging modules. The reviewer feedback correctly points out that switching to .to_string() introduces unnecessary heap allocations on hot paths (such as tracing spans and logging events). It is recommended to define a zero-allocation as_str(&self) -> &str method on ErrorType and have Display delegate to it, allowing the codebase to continue using cheap borrowed string slices in observability paths.

Comment thread src/gax-internal/src/observability/errors.rs Outdated
Comment thread src/gax-internal/src/observability/errors.rs Outdated
Comment thread src/gax-internal/src/observability/client_signals/with_client_logging.rs Outdated
Comment thread src/gax-internal/src/observability/client_signals/with_client_span.rs Outdated
Comment thread src/gax-internal/src/observability/client_signals/with_transport_logging.rs Outdated
Comment thread src/gax-internal/src/observability/client_signals/with_transport_span.rs Outdated
Comment thread src/gax-internal/src/observability/client_signals/with_transport_span.rs Outdated
Comment thread src/gax-internal/src/observability/grpc_tracing.rs Outdated
Comment thread src/gax-internal/src/observability/grpc_tracing.rs Outdated
Comment thread src/gax-internal/src/observability/http_tracing.rs Outdated
Comment thread src/gax-internal/src/observability.rs Outdated
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.89%. Comparing base (d9b1879) to head (67a6c19).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/gax-internal/src/observability/errors.rs 83.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5908      +/-   ##
==========================================
- Coverage   97.90%   97.89%   -0.01%     
==========================================
  Files         233      233              
  Lines       59205    59211       +6     
==========================================
+ Hits        57965    57967       +2     
- Misses       1240     1244       +4     

☔ 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 marked this pull request as ready for review June 17, 2026 19:09
@haphungw haphungw requested a review from a team as a code owner June 17, 2026 19:09
@haphungw haphungw enabled auto-merge (squash) June 17, 2026 19:10
@haphungw haphungw merged commit 5102ca3 into googleapis:main Jun 17, 2026
40 checks passed
@haphungw haphungw deleted the refactor-observability-errors branch June 17, 2026 19: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.

2 participants