feat: Add more attributes to golden signals metrics.#4135
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances observability by introducing new attributes to metrics. However, it introduces a potential Denial of Service (DoS) vulnerability in the metrics recording logic due to incorrect variable usage and missing null checks, which can lead to application crashes. Specifically, the transport() method in ApiTracerContext is undefined, there are logical errors in how url.domain and url.template attributes are populated, and the gcp.client.version attribute is missing. Additionally, Javadoc is missing for a new constructor parameter, and new tests are required to cover the newly added metric attributes.
|
🤖 I have created a release *beep* *boop* --- <details><summary>2.68.0</summary> ## [2.68.0](v2.67.0...v2.68.0) (2026-03-17) ### Features * Add client request duration metric. ([#4132](#4132)) ([6a76397](6a76397)) * Add more attributes to golden signals metrics. ([#4135](#4135)) ([59d0624](59d0624)) * **gax-httpjson:** add HttpJsonErrorParser utility ([#4137](#4137)) ([a1b7565](a1b7565)) * **generator:** add extra allowed modules that will not be removed from the monorepo if they are present ([#4124](#4124)) ([774fe6e](774fe6e)) * **o11y:** introduce `gcp.client.repo` and `gcp.client.artifact` attributes ([#4120](#4120)) ([105f644](105f644)) * **o11y:** Introduce `rpc.system.name` and `rpc.method` in gRPC ([#4121](#4121)) ([7ab6d2e](7ab6d2e)) * **o11y:** introduce server.port attribute ([#4128](#4128)) ([56aa343](56aa343)) ### Bug Fixes * add null checks for ApiTracerFactory in ClientContext ([#4122](#4122)) ([4b3dbe2](4b3dbe2)) * Decrease log level for directpath warnings outside GCE ([#4139](#4139)) ([c9651e7](c9651e7)) * **gax-grpc:** add pick_first fallback to direct path service config ([#4143](#4143)) ([b150fe9](b150fe9)) * Populate method level attributes in metrics recording ([#4149](#4149)) ([7b7e6c9](7b7e6c9)) * suppress warnings in generated projects for non-idiomatic durations ([#4119](#4119)) ([4206e6e](4206e6e)) * Use ServiceName + MethodName as the regex for Otel ([#2543](#2543)) ([b9ae73f](b9ae73f)) ### Documentation * **hermetic_build:** fix config field name in readme ([#4130](#4130)) ([a0c8f67](a0c8f67)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>2.68.0</summary> ## [2.68.0](googleapis/sdk-platform-java@v2.67.0...v2.68.0) (2026-03-17) ### Features * Add client request duration metric. ([#4132](googleapis/sdk-platform-java#4132)) ([487650e](googleapis/sdk-platform-java@487650e)) * Add more attributes to golden signals metrics. ([#4135](googleapis/sdk-platform-java#4135)) ([bc82dcb](googleapis/sdk-platform-java@bc82dcb)) * **gax-httpjson:** add HttpJsonErrorParser utility ([#4137](googleapis/sdk-platform-java#4137)) ([6fe2446](googleapis/sdk-platform-java@6fe2446)) * **generator:** add extra allowed modules that will not be removed from the monorepo if they are present ([#4124](googleapis/sdk-platform-java#4124)) ([6a440da](googleapis/sdk-platform-java@6a440da)) * **o11y:** introduce `gcp.client.repo` and `gcp.client.artifact` attributes ([#4120](googleapis/sdk-platform-java#4120)) ([4954de5](googleapis/sdk-platform-java@4954de5)) * **o11y:** Introduce `rpc.system.name` and `rpc.method` in gRPC ([#4121](googleapis/sdk-platform-java#4121)) ([3593c30](googleapis/sdk-platform-java@3593c30)) * **o11y:** introduce server.port attribute ([#4128](googleapis/sdk-platform-java#4128)) ([1b10e02](googleapis/sdk-platform-java@1b10e02)) ### Bug Fixes * add null checks for ApiTracerFactory in ClientContext ([#4122](googleapis/sdk-platform-java#4122)) ([ded1922](googleapis/sdk-platform-java@ded1922)) * Decrease log level for directpath warnings outside GCE ([#4139](googleapis/sdk-platform-java#4139)) ([5151f34](googleapis/sdk-platform-java@5151f34)) * **gax-grpc:** add pick_first fallback to direct path service config ([#4143](googleapis/sdk-platform-java#4143)) ([4934ad8](googleapis/sdk-platform-java@4934ad8)) * Populate method level attributes in metrics recording ([#4149](googleapis/sdk-platform-java#4149)) ([69aabf8](googleapis/sdk-platform-java@69aabf8)) * suppress warnings in generated projects for non-idiomatic durations ([#4119](googleapis/sdk-platform-java#4119)) ([8a0c565](googleapis/sdk-platform-java@8a0c565)) * Use ServiceName + MethodName as the regex for Otel ([#2543](googleapis/sdk-platform-java#2543)) ([8196b8f](googleapis/sdk-platform-java@8196b8f)) ### Documentation * **hermetic_build:** fix config field name in readme ([#4130](googleapis/sdk-platform-java#4130)) ([0d98c37](googleapis/sdk-platform-java@0d98c37)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>






This PR adds more attributes to metrics by introducing a getMetricsAttributes() in ApiTracerContext. It does not only add all known attributes, but also adds three new attributes to ApiTracerContext: serviceName(), urlDomain() and urlTemplate(). These three attributes are always empty for now and will be populated in future PRs.