Skip to content

feat(v2): add ClientMetrics initialization core#473

Merged
westarle merged 2 commits intogoogleapis:mainfrom
westarle:westarle/metrics-clientmetrics-core-v4
Mar 11, 2026
Merged

feat(v2): add ClientMetrics initialization core#473
westarle merged 2 commits intogoogleapis:mainfrom
westarle:westarle/metrics-clientmetrics-core-v4

Conversation

@westarle
Copy link
Copy Markdown
Contributor

@westarle westarle commented Mar 9, 2026

This PR introduces the foundational configuration parameters and data structures for OpenTelemetry duration metrics in Google Cloud Go client libraries.

  • Defines semantic OpenTelemetry constants that match our cross-language OpenTelemetry instrumentation specifications.
  • Defines the mapping constants generated clients will use to provide library-specific details to the underlying instrument initialization.
  • Provides the NewClientMetrics constructor to act as the central initialization registry for the OTel Meter and Float64Histogram.

We strictly validate against the standard semantic convention keys to ensure backwards compatibility while resolving versions.

@westarle westarle requested a review from a team as a code owner March 9, 2026 02:01
@quartzmo quartzmo changed the title impl(o11y): add ClientMetrics initialization core feat(v2): add ClientMetrics initialization core Mar 10, 2026
Comment thread v2/telemetry.go Outdated
Comment thread v2/telemetry.go
Comment thread v2/telemetry.go
Comment thread v2/telemetry.go Outdated
This PR introduces the foundational configuration parameters and
data structures for OpenTelemetry duration metrics in Google Cloud Go
client libraries.

Historically, generated Go clients lacked a straightforward architectural
injection point for OpenTelemetry instruments. This leads to gaps in
measuring time spent inside the `gax.Invoke` retry loop.

To address this, this PR does the following:

* Defines semantic OpenTelemetry constants that match our cross-language
  OpenTelemetry instrumentation specifications.
* Defines the mapping constants generated clients will use to provide
  library-specific details to the underlying instrument initialization.
* Provides the `NewClientMetrics` constructor to act as the central
  initialization registry for the OTel Meter and Float64Histogram.

We strictly validate against the standard semantic convention keys to
ensure backwards compatibility while resolving versions.
@westarle westarle force-pushed the westarle/metrics-clientmetrics-core-v4 branch from fd956d1 to 2c9b435 Compare March 11, 2026 00:58
@westarle westarle requested a review from shollyman March 11, 2026 00:59
@westarle westarle enabled auto-merge (squash) March 11, 2026 00:59
Copy link
Copy Markdown
Contributor

@shollyman shollyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one more comment for consideration, but approving in the current state.

Comment thread v2/telemetry.go
}

provider := config.provider
if provider == nil {
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.

nit: I see there's a number of these checks against config (clientMetricsOptions) that are variations of "if its not set, use this default".

One thing to consider is whether to add getter-style methods directly on the clientMetricsOptions struct that provide these defaults. It mostly down to how many consumers we expect to have read values from clientMetricsOptions, and whether consumers have special awareness or other side channels for data that inform how default values are generated.

Also, do we expect similar config options for the other observability features (tracing, logging)? Should we use a shared config type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to consider is whether to add getter-style methods directly on the clientMetricsOptions struct

See #480

do we expect similar config options for the other observability features (tracing, logging)? Should we use a shared config type?

I was hoping to see what emerges from our design as we put it in practice and before we lift our 'experimental' flags. How big a pain is it to converge on a single type later?

@westarle westarle merged commit f53618c into googleapis:main Mar 11, 2026
5 checks passed
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