Skip to content

test(metrics): add Cloud Storage client metrics validation tests - #5255

Open
alleaditya wants to merge 3 commits into
refactor-grpc-metrics-test-infrafrom
gosdk-metrics-validation-tests
Open

alleaditya wants to merge 3 commits into
refactor-grpc-metrics-test-infrafrom
gosdk-metrics-validation-tests

Conversation

@alleaditya

@alleaditya alleaditya commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Stacked on #5265.

Add end-to-end validation tests in internal/fs/storage_client_metrics_test.go for all 16 Cloud Storage client OpenTelemetry metrics (8 Standard + 8 Debug under instrumentation scope cloud.google.com/go/storage) wired through GCSFuse's gRPC storage client:

  • Standard metrics (GCP_STORAGE_GO_ENABLE_OTEL_METRICS=true): gcp/storage/client/operations, gcp/client/request/duration, gcp/storage/client/attempts, rpc/client/call/duration, gcp/storage/client/operation/ttfb, gcp/storage/client/errors, gcp/storage/client/response/body/size, and gcp/storage/client/request/body/size.
  • Debug metrics (GCP_STORAGE_GO_ENABLE_OTEL_DEBUG_METRICS=true): gcp/storage/client/network/bytes/received, gcp/storage/client/network/bytes/sent, gcp/storage/client/request/active, gcp/storage/client/network/tcp/connect/duration, gcp/storage/client/network/tls/handshake/duration, gcp/storage/client/stall/duration (both read-stall and resumable write-stall watchdog paths), gcp/storage/client/gfe/header_missing, and gcp/storage/client/auth/credential_refresh/duration (both OK and CLIENT_AUTHENTICATION_ERROR).
  • Supporting test helpers & fake-server hooks: Add WithScope, WithUnit, NonMonotonic, AtLeastSum, VerifyMetricNotPresent, and VerifyDataPointNotPresent in metrics/metrics_test_utils.go, and extend reflectFakeServer / setupGRPCMetricsFixture in internal/fs/grpc_metrics_test.go with hooks for TLS/OAuth, QueryWriteStatus, x-goog-gfe-service-time headers, multi-chunk reads, transient retries, read/write stalls, and in-flight stream synchronization.

Link to the issue in case of a bug fix.

Fixes b/586721467

Testing details

  1. Manual - Ran make build (go generate, goimports, go mod tidy, gofmt -s, go vet ./..., golangci-lint, go build ./...).
  2. Unit tests - go test -race -shuffle=on -count=3 ./internal/fs -run "TestGrpcMetrics|TestStorageClient" (~2.2s non-race suite runtime including the 1s WriteStall watchdog).
  3. Integration tests - Exercised full FUSE server -> gRPC StorageHandle -> in-process google.storage.v2.Storage fake server + ECDSA P-256 TLS + OAuth2 flows in internal/fs.

Any backward incompatible change? If so, please explain.

N/A

@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 introduces comprehensive integration tests for Go SDK Standard and Debug metrics, refactors the fake gRPC storage server to support advanced simulation scenarios (such as stalls, retries, and bidirectional streaming), and enhances the OpenTelemetry metric verification utilities with scope-specific lookups and detailed histogram assertions. Feedback on the changes highlights that modifying the GODEBUG environment variable at runtime via os.Setenv to enable fallback roots is ineffective because it is parsed at process startup, and recommends documenting this requirement for the external test environment instead.

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.24%. Comparing base (bcba7c7) to head (7c21134).

Files with missing lines Patch % Lines
metrics/metrics_test_utils.go 90.90% 3 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##           refactor-grpc-metrics-test-infra    #5255      +/-   ##
====================================================================
+ Coverage                             85.23%   85.24%   +0.01%     
====================================================================
  Files                                   181      181              
  Lines                                 19974    20005      +31     
====================================================================
+ Hits                                  17024    17054      +30     
- Misses                                 2949     2951       +2     
+ Partials                                  1        0       -1     
Flag Coverage Δ
unittests 85.24% <90.90%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch from b9a9985 to 8598114 Compare November 16, 2026 12:37
@alleaditya alleaditya changed the title test(metrics): add Go SDK OpenTelemetry metrics validation tests Nov 16, 2026
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch 3 times, most recently from 65ea4a2 to 5cc778b Compare November 17, 2026 04:07
@alleaditya
alleaditya changed the base branch from master to refactor-grpc-metrics-test-infra November 17, 2026 04:39
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch from 5cc778b to eab5500 Compare November 17, 2026 04:39
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch from eab5500 to abfb2b4 Compare November 17, 2026 04:46
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch from abfb2b4 to eccb3f9 Compare November 17, 2026 05:04
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch 2 times, most recently from 02cc578 to b813601 Compare November 17, 2026 05:30
@alleaditya
alleaditya added this pull request to stack #5266 November 17, 2026 05:46
@alleaditya

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 introduces comprehensive integration tests for Cloud Storage client Standard and Debug OpenTelemetry metrics. It expands the 'reflectFakeServer' in 'grpc_metrics_test.go' to support TLS, OAuth2 token exchanges, and various failure/stall simulations, and adds a new test suite in 'storage_client_metrics_test.go'. Additionally, 'metrics_test_utils.go' is enhanced with new verification options (such as scope, unit, and non-monotonicity checks). Feedback on the changes suggests asserting the success of 'AppendCertsFromPEM' and replacing thread-unsafe 'os.Setenv' calls with 't.Setenv' in the test TLS setup.

@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch from b813601 to 6399de3 Compare November 17, 2026 06:46
@alleaditya
alleaditya marked this pull request as ready for review November 17, 2026 08:09
@alleaditya
alleaditya requested a review from a team as a code owner November 17, 2026 08:09
@github-actions github-actions Bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Nov 17, 2026
@alleaditya alleaditya self-assigned this Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@alleaditya alleaditya added execute-perf-test Execute performance test in PR execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

1 similar comment
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

Add end-to-end validation tests in internal/fs/storage_client_metrics_test.go
for all 16 Cloud Storage client OpenTelemetry metrics (8 Standard + 8 Debug)
emitted under scope cloud.google.com/go/storage when wired through GCSFuse's
gRPC storage client:

- Add hermetic ECDSA P-256 x509 fallback-root TLS and service-account OAuth2
  token fixtures in internal/fs/storage_client_metrics_test.go, validating
  units, monotonicity, attributes, counts, sums, retry/stall/streaming edge
  cases, and env/config gating flags.
- Extend reflectFakeServer and setupGRPCMetricsFixture in
  internal/fs/grpc_metrics_test.go with simulation hooks for TLS/OAuth,
  QueryWriteStatus, x-goog-gfe-service-time headers, multi-chunk reads,
  transient retries, read/write stalls, and in-flight stream synchronization.
- Extend metrics/metrics_test_utils.go with the VerifyOptions and negative
  presence assertions used by these tests (WithScope, WithUnit, NonMonotonic,
  AtLeastSum, VerifyMetricNotPresent, VerifyDataPointNotPresent).
Verify pool.AppendCertsFromPEM succeeds inside ensureTestTLSFixture and replace
manual os.Setenv/os.Unsetenv manipulation with t.Setenv so GODEBUG is set and
restored safely under Go's test harness.
@alleaditya
alleaditya force-pushed the gosdk-metrics-validation-tests branch from 6399de3 to 7c21134 Compare November 24, 2026 06:22
@alleaditya alleaditya removed the execute-integration-tests-on-zb To run E2E tests on zonal bucket. label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

1 similar comment
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

Comment thread internal/fs/grpc_metrics_test.go Resolved
…ics tests

- Remove unused sh and mh fields from grpcMetricsTestFixture and unused
  sendGFEHeader field from grpcMetricsTestOptions.
- Fail fast on early SyncFile errors before BidiWriteObject entry while
  canceling and draining the sync goroutine cleanly on unwind.
- Return early from BidiWriteObject if the stream context is canceled
  while blocked.
- Trigger a single sequential ListObjects RPC via OpenDir/ReadDir in
  TestStorageClientDebugMetrics_CredentialRefreshFailure for deterministic
  Count=1 without errgroup cancellation races.
- Include gcp.storage.client.gfe.duration in storageClientDebugMetricNames
  negative checks and update doc comments.
- Use ReqIncreaseRate=0.25 in read-stall retry test config so attempt 2
  has 160ms headroom instead of 10.47ms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests execute-perf-test Execute performance test in PR remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

2 participants