Skip to content

impl(storage): add ServerUnreachedMetrics recorder for OTel server.unreached counter - #16714

Open
cpriti-os wants to merge 1 commit into
googleapis:mainfrom
cpriti-os:impl-storage-server-unreached-metrics
Open

cpriti-os wants to merge 1 commit into
googleapis:mainfrom
cpriti-os:impl-storage-server-unreached-metrics

Conversation

@cpriti-os

Copy link
Copy Markdown
Contributor

Adds the internal ServerUnreachedMetrics recorder for the gcp.storage.client.server.unreached OpenTelemetry counter (UInt64Counter, unit {request}).

Records failed attempts that did not reach Google Cloud Storage with the standard Storage base attributes (gcp.client.version, gcp.client.artifact, gcp.client.service, server.address) plus rpc.system.name, gcp.storage.operation, network.path, and error.type, propagating the explicit opentelemetry::context::Context and safely no-oping when the provider, meter, or instrument is null.

Also registers server_unreached_metrics.{h,cc,_test.cc} in Bazel and CMake build files.


Created by cpriti-o11y-agent

@cpriti-os
cpriti-os requested review from a team as code owners November 26, 2026 07:53
@cpriti-os
cpriti-os requested a review from kalragauri November 26, 2026 07:53
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 26, 2026

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

Copy link
Copy Markdown

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 ServerUnreachedMetrics class to track and record failed requests that do not reach Google Cloud Storage, along with corresponding unit tests and build configuration updates. The review feedback suggests simplifying the implementation and tests by replacing the custom SemanticVersionString() helper with the existing google::cloud::version_string() function, which also ensures pre-release or development suffixes are correctly preserved.

Comment on lines +44 to +48
std::string SemanticVersionString() {
return std::to_string(google::cloud::version_major()) + "." +
std::to_string(google::cloud::version_minor()) + "." +
std::to_string(google::cloud::version_patch());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

We can remove the redundant SemanticVersionString() helper function and use google::cloud::version_string() directly. This simplifies the code and ensures any pre-release or development suffixes are correctly preserved in the metrics.

opentelemetry::nostd::shared_ptr<
opentelemetry::metrics::MeterProvider> const& provider,
std::string server_address)
: client_version_(SemanticVersionString()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Use google::cloud::version_string() directly instead of SemanticVersionString().

    : client_version_(google::cloud::version_string()),

Comment on lines +124 to +127
std::string const expected_version =
std::to_string(google::cloud::version_major()) + "." +
std::to_string(google::cloud::version_minor()) + "." +
std::to_string(google::cloud::version_patch());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

We can simplify this by using google::cloud::version_string() directly instead of manually formatting the version components.

  std::string const expected_version = google::cloud::version_string();

@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.90722% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.78%. Comparing base (fa26249) to head (902964c).

Files with missing lines Patch % Lines
.../storage/internal/server_unreached_metrics_test.cc 97.05% 2 Missing ⚠️
...cloud/storage/internal/server_unreached_metrics.cc 96.55% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16714   +/-   ##
=======================================
  Coverage   92.78%   92.78%           
=======================================
  Files        2275     2277    +2     
  Lines      227981   228078   +97     
=======================================
+ Hits       211537   211633   +96     
- Misses      16444    16445    +1     

☔ 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.

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

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant