Skip to content

feat(gax): Add error attributes to golden signal metrics.#12564

Merged
blakeli0 merged 18 commits intomainfrom
metrics-attributes-update
Apr 2, 2026
Merged

feat(gax): Add error attributes to golden signal metrics.#12564
blakeli0 merged 18 commits intomainfrom
metrics-attributes-update

Conversation

@blakeli0
Copy link
Copy Markdown
Contributor

@blakeli0 blakeli0 commented Apr 1, 2026

This PR

  • Added error attributes to metrics
  • Added version as instrumentation version
  • Added ITOtelGoldenMetrics that verifies all attributes

blakeli0 added 9 commits April 1, 2026 17:03
This commit ensures that all required metrics attributes for Golden
Signals are fully implemented in sdk-platform-java.
Specifically:
- Always populate `rpc.response.status_code` for both gRPC and HTTP transports.
- Conditionally populate `http.response.status_code` only for HTTP transport.
- Add `error.type` attribute to metrics exclusively on operation failures.
- Ensured all other attributes (`gcp.client.service`, `rpc.system.name`, `rpc.method`, `url.domain`, `url.template`, `server.address`, `server.port`) are consistently populated from `ApiTracerContext.getMetricsAttributes()`.
Added additional test cases to GoldenSignalsMetricsTracerTest to ensure that ObservabilityUtils.extractErrorType is correctly translating various exceptions (like CancellationException, SocketTimeoutException, and IllegalArgumentException) into the appropriate error.type attributes during failure reporting.
Updated GoldenSignalsMetricsRecorder to automatically apply the library version retrieved from LibraryMetadata as the instrumentation version on the built OpenTelemetry Meter.
…Recorder

Instead of manually extracting properties and passing separate tracking arguments to GoldenSignalsMetricsRecorder, this passes the entire LibraryMetadata model and builds the telemetry setup dynamically.
Removed repetitive check for LibraryMetadata and artifactName from GoldenSignalsMetricsTracerFactory#withContext. Instead, GoldenSignalsMetricsRecorder gracefully handles missing metadata by acting as a no-op instead of creating an underlying OpenTelemetry instrument.
Extracted the metadata validation into a static `create` method inside `GoldenSignalsMetricsRecorder`. This allows the recorder to own the validation logic while allowing `GoldenSignalsMetricsTracerFactory` to cleanly bail out and return a `BaseApiTracerFactory` if telemetry cannot be correctly constructed, maximizing performance by avoiding any tracer overhead without duplicating checks.
Added unit tests to `GoldenSignalsMetricsRecorderTest` to explicitly verify that `GoldenSignalsMetricsRecorder.create()` correctly intercepts invalid `LibraryMetadata` states (null values, missing artifact name, empty artifact name) and returns `null` as expected.
Cleaned up instances of fully qualified class references (LibraryMetadata, Strings, Nullable) by introducing proper Java import statements across GoldenSignalsMetricsRecorder and its associated tests.
Added `ITOtelGoldenMetrics` alongside `ITOtelTracing` to ensure that Golden Signals are correctly collected with accurate dimensional attributes (e.g., service name, status code, error type, port, addressing) across both the gRPC and HTTP/JSON runtime transports.
@blakeli0 blakeli0 requested a review from a team as a code owner April 1, 2026 22:34
Copy link
Copy Markdown
Contributor

@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 refactors GoldenSignalsMetricsRecorder to use LibraryMetadata for instrumentation versioning and standardizes status attribute population in GoldenSignalsMetricsTracer and ObservabilityUtils. It also adds integration tests for OpenTelemetry metrics. Reviewers suggested simplifying metadata validation and ensuring the error.type attribute is consistently applied to cancelled operations.

@blakeli0 blakeli0 changed the title feat(observability): implement and verify golden signal metrics attributes feat(gax): Add error attributes to golden signal metrics. Apr 2, 2026
@blakeli0 blakeli0 force-pushed the metrics-attributes-update branch from dee16a4 to 18c0a49 Compare April 2, 2026 03:39
blakeli0 added 2 commits April 2, 2026 02:42
…te expectations and resolve test flakiness in ITOtelGoldenMetricsTest
@blakeli0 blakeli0 force-pushed the metrics-attributes-update branch 2 times, most recently from bac9623 to 232aeb8 Compare April 2, 2026 18:08
@blakeli0 blakeli0 merged commit 063dfe5 into main Apr 2, 2026
126 of 127 checks passed
@blakeli0 blakeli0 deleted the metrics-attributes-update branch April 2, 2026 19:56
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