Skip to content

feat(storage): promote server.unreached to Standard tier with gRPC and HTTP heuristics - #15229

Open
nidhiii-27 wants to merge 5 commits into
feat/storage-server-duration-metricfrom
feat/storage-server-unreached-metric
Open

nidhiii-27 wants to merge 5 commits into
feat/storage-server-duration-metricfrom
feat/storage-server-unreached-metric

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Summary

Stacked on #15228.

Promotes gcp.storage.client.server.unreached to the Standard metrics tier with unit {request} and wires server-reachability heuristics across both gRPC and HTTP/JSON transports.

Changes

  • StorageClientMetrics: move gcp.storage.client.server.unreached into the Standard tier (enableOtelMetrics), update unit to {request}, and add recordServerUnreached(Context, String operationName, String networkPath, String errorType) emitting exact 8-key attributes (gcp.client.service, gcp.client.version, gcp.client.artifact, rpc.system.name, server.address, gcp.storage.operation, network.path, error.type).
  • StorageGrpcMetricsInterceptor: detect unreached server failures on gRPC using DirectPath/CloudPath response header & trailer heuristics (receivedServerHeaders, x-guploader-uploadid, ambiguous client abort checks, pre-server error types).
  • StorageHttpMetricsInterceptor: detect unreached server failures on HTTP using X-GUploader-UploadID / X-Goog-Gfe-Service-Time response markers and HttpIOExceptionHandler connection/transport failures.
  • Unit tests in StorageClientMetricsTest, StorageGrpcMetricsInterceptorTest, and StorageHttpMetricsInterceptorTest.

[Generated-by: AI]

…d HTTP heuristics

Promote gcp.storage.client.server.unreached to the Standard metrics tier
with unit "{request}" and record exact 8-key attributes across gRPC
(DirectPath/CloudPath heuristics) and HTTP (X-GUploader-UploadID /
X-Goog-Gfe-Service-Time markers and IOException handler).

[Generated-by: AI]

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request promotes the gcp.storage.client.server.unreached metric from debug to standard tier, implementing tracking logic in both gRPC and HTTP interceptors along with comprehensive unit tests. The review feedback highlights critical bugs where successful requests lacking specific headers (common in local tests or emulators) are incorrectly classified as unreached, causing NullPointerException crashes due to passing null error types to OpenTelemetry's AttributesBuilder. Actionable suggestions are provided to safely handle successful requests and defensively default null error types to prevent runtime crashes.

…server-unreached-metric

Resolve StorageHttpMetricsInterceptor conflicts by dropping the isRetry parameter from
recordResponse (retries now come from the pending-retry hook) while keeping the per-response
server.unreached evaluation, and drop the duplicated StorageClientMetricsTest
recordServerUnreached exact-attribute test (covered end-to-end by the interceptor tests).

[Generated-by: AI]
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 26, 2026 06:05
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 26, 2026 06:05

@cpriti-os cpriti-os 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.

Initial review

urlTemplate,
StorageErrorTypeMapper.STATUS_CONNECTION_ERROR);
StorageMetricsContext ctx = StorageMetricsContext.current();
metrics.recordServerUnreached(

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.

HttpIOExceptionHandler also fires on SocketTimeoutException read timeouts and hides DNS/TLS subtypes, so can we record server.unreached where the actual IOException is available instead of counting every IOException as CONNECTION_ERROR?

Metadata trailerNonEmpty = new Metadata();
trailerNonEmpty.put(Metadata.Key.of("x-custom-trailer", Metadata.ASCII_STRING_MARSHALLER), "v");

// DirectPath & unknown: only pre-server errors with no headers/trailers/stats/OK are unreached.

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: This comment says unknown follows the DirectPath pre-server rule, but isServerUnreached routes NETWORK_PATH_UNKNOWN through the CloudPath branch, so could we align the comment (or branch) and add a non-pre-server case like bare UNAVAILABLE on Attributes.EMPTY?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull Request generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants