refactor(o11y): minimize internal API surface and gate errors under common feature#5908
Conversation
…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.
There was a problem hiding this comment.
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Refactor
gaxierrors tracing observability module to minimize the public API surface and optimize feature gating for downstream usage.This is a prerequisite for adding
error.typespan attributes recording to the LRO span (#5895), ensuringgoogle-cloud-lrocan fetch error tracing categories without bloating its dependency footprint.