GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
|
| long endNanos = clock.nanoTime(); | ||
| boolean handled = | ||
| existingUnsuccessfulHandler.handleResponse(req, response, supportsRetry); | ||
| if (handled && recorded.compareAndSet(false, true)) { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| if (delegate != null) { | ||
| delegate.initialize(request); | ||
| } | ||
| if (metrics == null || metrics.getHttpClientRequestDuration() == null) { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| this.networkPath = networkPath; | ||
| } | ||
|
|
||
| static void recordHttpRequestDuration( |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| existingResp.interceptResponse(response); | ||
| } | ||
| if (recorded.compareAndSet(false, true)) { | ||
| int statusCode = response.getStatusCode(); |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| 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])) { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| @Test | ||
| public void extractUrlTemplate_cases() { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| @Test | ||
| public void initialize_200Ok_recordsDurationWithoutErrorType() throws IOException { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| @Test | ||
| public void initialize_404NotFound_recordsErrorType() throws IOException { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
…into feat/storage-http-request-duration
- 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]
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.