GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(storage): add http.client.request.duration metric for HTTP requests by nidhiii-27 · Pull Request #14744 · googleapis/google-cloud-java

Conversation

@nidhiii-27

@nidhiii-27 nidhiii-27 commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Instruments HTTP/JSON storage requests to record http.client.request.duration OpenTelemetry histogram metrics.

  • Adds StorageHttpMetricsInterceptor to measure per-request duration and attach rpc.system.name, http.request.method, http.response.status_code, network.path, url.template, server.address, and error.type attributes across normal responses and IOException failures.
  • Wires StorageHttpMetricsInterceptor via StorageOptions.decorateWithMetrics and HttpStorageRpc.
  • Adds unit tests in StorageHttpMetricsInterceptorTest.

Stacked on #14743.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction
@nidhiii-27
feat: add http.client.request.duration metric for HTTP requests
2590f0e
@nidhiii-27 nidhiii-27 mentioned this pull request Oct 23, 2026
feat(storage): add gcp.storage.client.ttfb metric #14745
Open
gemini-code-assist[bot]
gemini-code-assist Bot reviewed Oct 23, 2026
View reviewed changes

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

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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 the StorageHttpMetricsInterceptor class to record HTTP client metrics, such as request duration, using OpenTelemetry. It integrates this interceptor into StorageOptions and HttpStorageRpc to decorate request initializers, and adds comprehensive unit tests. Feedback on the changes suggests initializing the recorded AtomicBoolean to true instead of false to prevent recording metrics for requests that fail before execution begins.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@nidhiii-27
fix(storage): address PR #14744 review comments and align HTTP durati…
510824a
…on metrics

[Generated-by: AI]
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 5, 2026 09:03
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 5, 2026 09:03
nidhiii-27 added 5 commits November 5, 2026 09:14
@nidhiii-27
fix(storage): merge base branch and align StorageHttpMetricsInterceptor
88cef70
Merge updated feat/storage-rpc-call-duration base branch, use OpenTelemetryBootstrappingUtils.extractServerAddress, pass String status codes to KEY_HTTP_RESPONSE_STATUS_CODE, wire batchRequestInitializer on overflow batches, and refine StorageHttpMetricsInterceptor Javadoc.

[Generated-by: AI]
@nidhiii-27
Merge branch 'feat/storage-rpc-call-duration' into feat/storage-http-…
57e750a
…request-duration
@nidhiii-27
Merge branch 'feat/storage-rpc-call-duration' into feat/storage-http-…
9a1c760
…request-duration
@nidhiii-27
Merge branch 'feat/storage-rpc-call-duration' into feat/storage-http-…
759422a
…request-duration
@nidhiii-27
refactor(storage): simplify extractUrlTemplate and move recordHttpReq…
df4a503
…uestDuration to StorageMetricsContext

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested review from Dhriti07 and cpriti-os November 5, 2026 09:54
cpriti-os
cpriti-os requested changes Nov 5, 2026
View reviewed changes
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

nidhiii-27 added 3 commits November 7, 2026 19:12
@nidhiii-27
Merge branch 'feat/storage-rpc-call-duration' into feat/storage-http-…
d015a76
…request-duration
@nidhiii-27
fix(storage): resolve PR #14744 review comments in StorageHttpMetrics…
610bd86
…Interceptor

- Merge updated base branch feat/storage-rpc-call-duration (including #14694)
- Update HttpIOExceptionHandler error type to StorageErrorTypeMapper.STATUS_CONNECTION_ERROR
- Return "/storage/v1/b" in extractV1UrlTemplate when rest is "b" (CreateBucket / ListBuckets)

[Generated-by: AI]
@nidhiii-27
test(storage): align RetryingMetricsTest with DEADLINE_EXCEEDED error…
baa4283
… mapping

After merging StorageErrorTypeMapper updates from #14694, Status.DEADLINE_EXCEEDED
maps to DEADLINE_EXCEEDED while SocketTimeoutException maps to TIMEOUT. Update
recordAttemptError_specificExceptions_mappedToCanonicalTypes to assert 1 count
each for DEADLINE_EXCEEDED, TIMEOUT, and DNS_FAILURE.

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested a review from cpriti-os November 9, 2026 10:50
cpriti-os
cpriti-os requested changes Nov 11, 2026
View reviewed changes

@cpriti-os cpriti-os left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the fixes, a few follow-ups inline.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

nidhiii-27 added 3 commits November 12, 2026 06:05
@nidhiii-27
fix(storage): merge feat/storage-rpc-call-duration and use long statu…
d6b4def
…sCode for http.client.request.duration

[Generated-by: AI]
@nidhiii-27
Merge branch 'feat/storage-rpc-call-duration' into feat/storage-http-…
a92031d
…request-duration
@nidhiii-27
fix(storage): address PR review feedback on HTTP request duration int…
f71f98a
…erceptor

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested a review from cpriti-os November 12, 2026 08:59
@nidhiii-27
Merge branch 'feat/storage-rpc-call-duration' into feat/storage-http-…
f8d3db1
…request-duration

[Generated-by: AI]
cpriti-os
cpriti-os reviewed Nov 13, 2026
View reviewed changes
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

nidhiii-27 added 2 commits November 16, 2026 12:18
@nidhiii-27
Merge remote-tracking branch 'origin/feat/storage-rpc-call-duration' …
dfae3dd
…into feat/storage-http-request-duration
@nidhiii-27
fix(storage): address follow-up review comments on PR #14744
d36f02b
- Clarify StorageHttpMetricsInterceptor Javadoc on download header timing
- Capture end timestamp before delegating to UnsuccessfulResponseHandler so 401 duration excludes token refresh
- Restore {entity} and {notification} URL template placeholders on acl and notificationConfigs paths
- Add unit tests for notificationConfigs and UnsuccessfulResponseHandler returning false on 404

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested a review from cpriti-os November 17, 2026 07:13
cpriti-os
cpriti-os approved these changes Nov 17, 2026
View reviewed changes
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Outdated
long endNanos = clock.nanoTime();
boolean handled =
existingUnsuccessfulHandler.handleResponse(req, response, supportsRetry);
if (handled && recorded.compareAndSet(false, true)) {

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Batch parts still hit this path: BatchRequest's interceptor runs each part's execute interceptor, and BatchUnparsedResponse then calls the part's unsuccessful handler with a fake response, so a 401 part records a point spanning the whole batch. Can we add response.getRequest() == req to this condition, and swap the pre-execute IOException test for one covering this case?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Outdated
if (delegate != null) {
delegate.initialize(request);
}
if (metrics == null || metrics.getHttpClientRequestDuration() == null) {

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

metrics can't be null here since decorateWithMetrics only wraps when it's non-null, so let's drop @Nullable, this check, the one in recordDuration, and the metricsDisabled test. The Math.max(0.0, ...) and "UNKNOWN" method fallback below are also unreachable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...orage/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageMetricsContext.java Outdated
this.networkPath = networkPath;
}

static void recordHttpRequestDuration(

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can we make this an instance method on StorageClientMetrics next to recordRpcCallDuration and build from baseAttributes like it does? That already carries rpc.system.name and the configured server.address, so resolveServerAddress, defaultServerAddress and the host constructor arg can go.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Outdated
existingResp.interceptResponse(response);
}
if (recorded.compareAndSet(false, true)) {
int statusCode = response.getStatusCode();

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This duplicates the error.type derivation in the unsuccessful handler above. Can we sample the end time first in both hooks and call a single recordResponse(req, start, end, statusCode) that owns the >= 400 rule, and drop the 4-arg recordDuration overload?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...ogle-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java Outdated
if ("acl".equals(segments[2]) || "defaultObjectAcl".equals(segments[2])) {
return "/storage/v1/b/{bucket}/" + segments[2] + "/{entity}";
}
if ("notificationConfigs".equals(segments[2]) || "notifications".equals(segments[2])) {

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

HttpStorageRpc never issues notifications, copyTo or watchAll (it uses notificationConfigs and rewriteTo), so let's drop those branches and the matching test rows.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java
}

@Test
public void extractUrlTemplate_cases() {

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can we drive extractUrlTemplate_cases from a {url, template} table with assertWithMessage(url)? While here, drop the copyTo/watchAll/null rows and the query-string duplicates since only getRawPath() is used.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java Outdated
}

@Test
public void initialize_200Ok_recordsDurationWithoutErrorType() throws IOException {

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can we combine the 200/308/503 tests into one table over status and expected error.type? A small durationPoints() helper would also replace the collectAllMetrics().stream().filter(...) block repeated across the file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java Outdated
}

@Test
public void initialize_404NotFound_recordsErrorType() throws IOException {

@cpriti-os cpriti-os Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This plain-404 test is covered by the handler-returns-false 404 test; same for networkIOException (covered by the retry test) and chainsExistingDelegateAndInterceptors, whose exec/resp flags can move onto the 200 case.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nidhiii-27 nidhiii-27 Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
nidhiii-27 added 2 commits November 18, 2026 08:51
@nidhiii-27
Merge remote-tracking branch 'origin/feat/storage-rpc-call-duration' …
be76576
…into feat/storage-http-request-duration
@nidhiii-27
fix(storage): address review comments on HTTP request duration metrics
572ea33
- Move recordHttpRequestDuration onto StorageClientMetrics building from baseAttributes and drop resolveServerAddress/host
- Guard UnsuccessfulResponseHandler against BatchUnparsedResponse fake responses via response.getRequest() == req
- Remove unreachable null/Math.max/UNKNOWN guards and unissued notifications/copyTo/watchAll URL template branches
- Unify recordResponse helper sampling endNanos first across response hooks
- Consolidate StorageHttpMetricsInterceptorTest into table-driven tests and add real BatchRequest 401 part retry test

[Generated-by: AI]

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

Reviewers

@cpriti-os cpriti-os cpriti-os approved these changes
@Dhriti07 Dhriti07 Awaiting requested review from Dhriti07
+1 more reviewer
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@nidhiii-27 @cpriti-os
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.