Commit 53f1991
authored
feat(auth): Implement Actionable Errors logging for HTTP requests (#14265)
This PR introduces structured, OTel-compliant telemetry logging for
actionable errors within the `google-cloud-go/auth` HTTP transport
wrapper (`otelAttributeTransport`).
Key implementations include:
* **Safe Response Cloning:** Adds a `cloneResponse` mechanism that
buffers up to 1MB of the HTTP response body to parse error payloads
(like quota limits or permission errors) and uses
`io.MultiReader` to transparently stitch the stream back together. This
ensures the downstream generated client can still read the
`http.Response.Body` without hitting stream exhaustion or
OOM errors.
* **Inline Transport Logging:** Introduces `readResponseError` to
extract semantic attributes (e.g., `error.type`, `ErrorInfo` metadata)
from the cloned response. The structured log is
emitted inline via `slog` directly within the `RoundTrip`'s `onError`
hook, ensuring it properly correlates with low-level T4 network spans.
* **Feature Gated:** The entire logging execution is strictly gated
behind the `gax.IsFeatureEnabled("LOGGING")` experimental flag to
guarantee zero allocations when disabled.
* **Testing:** Updates `httptransport_otel_test.go` to validate error
mappings, OTel semantic conventions, and structured JSON payload formats
with high coverage.1 parent efe2e3a commit 53f1991
4 files changed
Lines changed: 882 additions & 60 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
37 | 37 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
474 | 479 | | |
475 | 480 | | |
476 | | - | |
| 481 | + | |
477 | 482 | | |
478 | 483 | | |
479 | 484 | | |
480 | 485 | | |
481 | | - | |
| 486 | + | |
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
| |||
0 commit comments