Repository navigation
feat(storage): support DirectPath over Interconnect in Cloud Monitoring and register channel_creation_latency view - #15025
nidhiii-27 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces tracking for gRPC channel creation latency metrics and refactors endpoint parsing in OpenTelemetryBootstrappingUtils to be more robust, particularly for C2P and DirectPath interconnect hosts. It also adds corresponding unit tests to validate these changes. The review feedback points out a redundant check in the stream filter of getCloudMonitoringEndpoint and suggests simplifying it using a method reference on resolvedHost to improve clarity and correctness.
…ng and register channel_creation_latency view - Register storage.googleapis.com/internal/client/channel_creation_latency histogram view in OpenTelemetryBootstrappingUtils.createMeterProvider. - Expose MeterProvider from enableGrpcMetrics via GrpcMetricsChannelConfigurator implementing Supplier<MeterProvider> while preserving the existing method signature. - Update getCloudMonitoringEndpoint to support DirectPath over Cloud Interconnect endpoints (storage-direct.googleapis.com, storage-preprod-direct.sandbox.googleapis.com, storage-direct.<universeDomain>, and google-c2p:/// / google-c2p-experimental:/// targets with query/fragment parameters) with defensive null/empty handling. - Add unit tests in OpenTelemetryBootstrappingUtilsTest. [Generated-by: AI]
[Generated-by: AI]
[Generated-by: AI]
a306a43 to
640013f
Compare
[Generated-by: AI]
…cy recorder [Generated-by: AI]
kalragauri
left a comment
There was a problem hiding this comment.
A few notes on the description:
- It lists
storage-direct.googleapis.comand the preprod host as newly handled, but both already resolve tomonitoring.googleapis.comonmain. The actual changes are the universe-domain host, query and fragment stripping, the experimental scheme, and null handling. - Host matching moved from
containsto exact equality. That is a behavior change worth calling out. createChannelCreationLatencyRecorderand theSupplier<MeterProvider>have no production caller in this PR. A link to #15065, where they are wired in, would help reviewers.
| String match = | ||
| ImmutableList.of(canonicalEndpoint, privateEndpoint, restrictedEndpoint).stream() | ||
| .filter(s -> endpoint.contains(s) || endpoint.contains("google-c2p:///" + s)) | ||
| .filter(resolvedHost::contains) |
There was a problem hiding this comment.
resolvedHost::contains can now match canonicalEndpoint, which was unreachable before the outer checks moved from contains to equals. For example, storage.googleapis.com.:443 (trailing dot) now returns storage.googleapis.com:443 instead of monitoring.googleapis.com:443.
Consider dropping canonicalEndpoint from this list, or matching the private and restricted hosts exactly.
| } | ||
|
|
||
| @Test | ||
| public void getCloudMonitoringEndpoint_directPathInterconnectAndC2pEndpoints() { |
There was a problem hiding this comment.
Most rows in this table also pass without the production change: only the storage-direct.apis-tpclp.goog and null rows fail on main. The two ?force-xds rows use port 443, which is also the default, so they do not show that the query string is stripped.
Consider adding a row such as google-c2p:///storage-direct.googleapis.com:8443?force-xds expecting port 8443.
| || host.equals("storage-direct." + universeDomain))) { | ||
| metricServiceEndpoint = "monitoring." + universeDomain; | ||
| } else if (!endpoint.contains("storage.googleapis.com")) { | ||
| } else if (!host.equals("storage.googleapis.com") && !isDirectPathInterconnectHost(host)) { |
There was a problem hiding this comment.
isDirectPathInterconnectHost(host) does not change the result: neither host contains storage., private. or restricted. plus the domain, so the branch below leaves monitoring.googleapis.com in place.
Is the check, and its two constants, needed? If it is kept for readability, a short comment saying so would help.
|
|
||
| @SuppressWarnings("rawtypes") // ManagedChannelBuilder | ||
| static final class GrpcMetricsChannelConfigurator | ||
| implements ChannelConfigurator, Supplier<MeterProvider> { |
There was a problem hiding this comment.
IIUC, implements Supplier<MeterProvider> makes the provider reachable only while the caller holds this exact type. ChannelConfigurator.andThen returns a plain lambda, so any later composition silently drops the provider and the recorder becomes a no-op.
Should we return a small holder with both the configurator and the provider from a package-private overload?
| || DIRECT_PATH_INTERCONNECT_PREPROD_HOST.equals(host); | ||
| } | ||
|
|
||
| private static String extractHostFallback(String endpoint) { |
There was a problem hiding this comment.
extractHostFallback only runs when HostAndPort.fromString rejects the input, and the one test that reaches it ([::1]:invalid) expects the default endpoint whatever host comes back.
Please add a case with a host such as storage.my-universe.com:99999 with universe my-universe.com expecting monitoring.my-universe.com:443.
| BiConsumer<String, Duration> noopRecorder = | ||
| OpenTelemetryBootstrappingUtils.createChannelCreationLatencyRecorder(null); | ||
| noopRecorder.accept("CloudPath", Duration.ofMillis(10)); | ||
| assertThat(metricReader.collectAllMetrics()).isEmpty(); |
There was a problem hiding this comment.
metricReader belongs to unusedProvider, which is never passed to the recorder, so this assertion holds for any implementation. The test really checks that accept does not throw.
Summary
Adds Cloud Monitoring endpoint support for DirectPath over Cloud Interconnect (DP over GCI) and registers the
channel_creation_latencyOpenTelemetry histogram view and recorder ingoogle-cloud-storage.Key Changes
OpenTelemetryBootstrappingUtils:storage.googleapis.com/internal/client/channel_creation_latencyhistogram view increateMeterProviderviaregisterGrpcChannelViews.createChannelCreationLatencyRecorder(configured with explicit seconds-scale latency bucket boundaries advice andtransport_typeattribute) for recording first-channel creation latency.MeterProviderfromenableGrpcMetricsviaGrpcMetricsChannelConfigurator implements ChannelConfigurator, Supplier<MeterProvider>while preserving the existing method signature.getCloudMonitoringEndpointto handlegoogle-c2p:///andgoogle-c2p-experimental:///targets with query/fragment parameters,storage-direct.googleapis.com,storage-preprod-direct.sandbox.googleapis.com,storage-direct.<universeDomain>, and IPv6 literals, with defensive null/empty handling.OpenTelemetryBootstrappingUtilsTest:registerGrpcChannelViewsseconds-scale bucket boundaries,createChannelCreationLatencyRecorder, andGrpcMetricsChannelConfigurator.