Skip to content

feat(gapic): ClientMetrics Integration for Go GAPIC#1709

Merged
westarle merged 5 commits intogoogleapis:mainfrom
westarle:westarle/metrics-generator-v4
Mar 20, 2026
Merged

feat(gapic): ClientMetrics Integration for Go GAPIC#1709
westarle merged 5 commits intogoogleapis:mainfrom
westarle:westarle/metrics-generator-v4

Conversation

@westarle
Copy link
Copy Markdown
Contributor

@westarle westarle commented Mar 14, 2026

This PR integrates gax.ClientMetrics support into the gapic-generator-go, enabling standardized OpenTelemetry instrumentation for client libraries according to CLO v1 standards.

Changes to Generated Clients

  • Constructing a client now automatically initializes ClientMetrics using gax.NewClientMetrics when the METRICS feature is enabled.
  • RPC methods now inject telemetry context (e.g., rpc.method, url.template) into the request context using callctx.WithTelemetryContext before reaching the transport layer.
  • Added the OpenTelemetryMetricsFeature ("open_telemetry_metrics") to the generator's internal feature-enablement system. The Go code is guarded by gax.IsFeatureEnabled("METRICS")

Test Improvements

  • added support for 'features' in the tests to generate .want golden files with different feature combinations

Depends on googleapis/gax-go#479

@westarle westarle force-pushed the westarle/metrics-generator-v4 branch 5 times, most recently from 0d8d577 to 9422622 Compare March 15, 2026 03:56
@westarle westarle added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 15, 2026
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch 4 times, most recently from 2be585e to 98c706b Compare March 16, 2026 04:04
@westarle westarle marked this pull request as ready for review March 16, 2026 04:05
@westarle westarle requested a review from a team as a code owner March 16, 2026 04:05
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch from 98c706b to 2c8acef Compare March 16, 2026 04:12
Comment thread internal/gengapic/gengrpc.go Outdated
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch 3 times, most recently from 983d355 to fa0ccaf Compare March 16, 2026 21:49
Comment thread internal/gengapic/gengapic.go
Comment thread internal/gengapic/gengrpc.go
Comment thread internal/gengapic/genrest.go
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch from fa0ccaf to dffdb5a Compare March 16, 2026 22:06
@quartzmo quartzmo changed the title impl(gapic): ClientMetrics Integration for Go GAPIC feat(gapic): ClientMetrics Integration for Go GAPIC Mar 16, 2026
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch from dffdb5a to 7f6b159 Compare March 16, 2026 23:39
Copy link
Copy Markdown
Contributor Author

@westarle westarle left a comment

Choose a reason for hiding this comment

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

I added the params for TRACING as well, I think we are going to need them (we expect e.g. "url_template" to be set in Auth.)

Comment thread internal/gengapic/gengapic.go
Comment thread internal/gengapic/gengrpc.go
Comment thread internal/gengapic/genrest.go
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch from 7f6b159 to 83f1503 Compare March 16, 2026 23:47
@westarle westarle requested a review from quartzmo March 16, 2026 23:52
@westarle westarle removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 18, 2026
Comment thread internal/gengapic/gengrpc.go Outdated
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch from dc9887b to 985a080 Compare March 18, 2026 22:16
Based on PR 7 feedback from @quartzmo, this avoids a guaranteed reallocation per RPC call by merging WithClientMetrics into the options array directly on the client at initialization.
@westarle westarle force-pushed the westarle/metrics-generator-v4 branch from 985a080 to d1cc11f Compare March 19, 2026 04:22
@westarle westarle requested a review from quartzmo March 19, 2026 04:29
@westarle westarle enabled auto-merge (squash) March 19, 2026 23:11
@westarle westarle merged commit 719ba65 into googleapis:main Mar 20, 2026
8 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