Skip to content

feat(storage): export gRPC channel creation latency metric by transport type - #16538

Merged
kalragauri merged 4 commits into
googleapis:mainfrom
kalragauri:feat/dp-channel-latency
Oct 9, 2026
Merged

kalragauri merged 4 commits into
googleapis:mainfrom
kalragauri:feat/dp-channel-latency

Conversation

@kalragauri

Copy link
Copy Markdown
Contributor

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 by transport_type (CloudPath, DirectPath, or DirectPathInterconnect).

Key Changes

  • channel_creation_latency histogram & callback seam (channel_metrics.{h,cc}, channel_telemetry.{h,cc}, storage_stub_factory.cc):
    • Extends StartChannelTelemetry() with a ChannelReadyCallback, 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 the internal/client/channel_creation_latency double histogram once per stub creation under the gl-cpp instrumentation scope, and records the elapsed time with the transport_type label.
    • Returns an empty callback when built without GOOGLE_CLOUD_CPP_STORAGE_WITH_OTEL_METRICS, or when no meter provider was registered for the client's authority (metrics disabled via EnableGrpcMetricsOption, or no monitoring project available).
  • Internal metric routing & latency histogram view (metrics_exporter_options.{h,cc}, metrics_meter_provider.{h,cc}):
    • MetricsExporterOptions() routes instruments prefixed with internal/client/ to storage.googleapis.com/internal/client/<name>, while gRPC's built-in instruments stay under storage.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).
  • Shared, thread-safe MeterProvider lookup (metrics_exporter_impl.{h,cc}):
    • ExporterRegistry now retains the MeterProvider built by EnableGrpcMetricsImpl() per authority and exposes FindMeterProvider(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.
    • Reusing the existing provider means channel_creation_latency shares one periodic exporter with gRPC's metrics and inherits the customer's EnableGrpcMetricsOption opt-out, export period/timeout, and monitoring project, without a second exporter.

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Oct 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 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.

Comment thread google/cloud/storage/internal/grpc/channel_metrics.cc Outdated
Comment thread google/cloud/storage/internal/grpc/channel_metrics.cc Outdated
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.97987% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.36%. Comparing base (b60d64c) to head (b03e1b3).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...loud/storage/internal/grpc/channel_metrics_test.cc 98.00% 3 Missing ⚠️
...ud/storage/internal/grpc/channel_telemetry_test.cc 84.21% 3 Missing ⚠️
...oud/storage/internal/grpc/metrics_exporter_impl.cc 94.73% 2 Missing ⚠️
...age/internal/grpc/metrics_exporter_options_test.cc 91.66% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalragauri
kalragauri marked this pull request as ready for review October 6, 2026 10:58
@kalragauri
kalragauri requested review from a team as code owners October 6, 2026 10:58

@v-pratap v-pratap left a comment

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.

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.

Comment thread google/cloud/storage/internal/grpc/channel_metrics.cc
Comment thread google/cloud/storage/internal/grpc/channel_metrics.cc
Comment thread google/cloud/storage/internal/grpc/channel_metrics_test.cc Outdated
@kalragauri
kalragauri enabled auto-merge (squash) October 9, 2026 04:48
@kalragauri
kalragauri merged commit 78b7a16 into googleapis:main Oct 9, 2026
69 checks passed
@kalragauri
kalragauri deleted the feat/dp-channel-latency branch October 9, 2026 09:20

This branch was successfully deployed

1 active deployment
false — b03e1b3e Deployed Oct 9, 2026 by kalragauri via Save PR ref #12368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants