Repository navigation
feat(storage): export gRPC channel creation latency metric by transport type - #16538
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces gRPC channel creation latency metrics tracking using OpenTelemetry. It adds a new channel_creation_latency histogram under the internal storage.googleapis.com/internal/client/ namespace, sharing the exporter and meter provider with gRPC's own metrics. The changes integrate a ChannelReadyCallback into the channel telemetry lifecycle and stub factory, supported by comprehensive unit tests. The review feedback correctly identifies two style guide violations in channel_metrics.cc where absl::string_view was used instead of std::string_view.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16538 +/- ##
==========================================
+ Coverage 92.35% 92.36% +0.01%
==========================================
Files 2263 2265 +2
Lines 218651 219046 +395
==========================================
+ Hits 201933 202329 +396
+ Misses 16718 16717 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
v-pratap
left a comment
There was a problem hiding this comment.
The channel_creation_latency histogram integration, internal/client/ metric routing, and thread-safe ExporterRegistry lookup look very clean. Left a few comments on channel_metrics.cc and channel_metrics_test.cc around guarding against a null histogram from CreateDoubleHistogram(), honoring per-client EnableGrpcMetricsOption(false) when a provider was already registered for the same authority, and asserting the recorded latency value in seconds.
This PR adds
storage.googleapis.com/internal/client/channel_creation_latency: an OpenTelemetry histogram, in seconds, of the elapsed time from gRPC stub creation (i.e. client construction) until the first gRPC channel in the pool becomes ready, labeled bytransport_type(CloudPath,DirectPath, orDirectPathInterconnect).Key Changes
channel_creation_latencyhistogram & callback seam (channel_metrics.{h,cc},channel_telemetry.{h,cc},storage_stub_factory.cc):StartChannelTelemetry()with aChannelReadyCallback, invoked only when the first channel becomes ready (status.ok()). Failed, timed-out, or abandoned connection attempts are not recorded, so the timeout value does not skew the histogram.MakeChannelMetricsCallback()creates theinternal/client/channel_creation_latencydouble histogram once per stub creation under thegl-cppinstrumentation scope, and records the elapsed time with thetransport_typelabel.GOOGLE_CLOUD_CPP_STORAGE_WITH_OTEL_METRICS, or when no meter provider was registered for the client's authority (metrics disabled viaEnableGrpcMetricsOption, or no monitoring project available).metrics_exporter_options.{h,cc},metrics_meter_provider.{h,cc}):MetricsExporterOptions()routes instruments prefixed withinternal/client/tostorage.googleapis.com/internal/client/<name>, while gRPC's built-in instruments stay understorage.googleapis.com/client/.MakeGrpcMeterProvider()registers a latency histogram view (MakeLatencyHistogramBoundaries(), 2ms buckets up to 100ms, then widening up to 5 minutes) for(gl-cpp, internal/client/channel_creation_latency).MeterProviderlookup (metrics_exporter_impl.{h,cc}):ExporterRegistrynow retains theMeterProviderbuilt byEnableGrpcMetricsImpl()per authority and exposesFindMeterProvider(authority). Provider creation and global gRPC plugin registration happen under the registry mutex, so concurrent clients for the same authority never observe a partially initialized entry.channel_creation_latencyshares one periodic exporter with gRPC's metrics and inherits the customer'sEnableGrpcMetricsOptionopt-out, export period/timeout, and monitoring project, without a second exporter.