Repository navigation
Conversation
There was a problem hiding this comment.
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.
| 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()); | ||
| } |
There was a problem hiding this comment.
Same point as my reply on #16712: I would keep SemanticVersionString() here. version_string() returns v<major>.<minor>.<patch> plus any pre-release and build metadata, so gcp.client.version would no longer match what OperationMetrics and AttemptMetrics emit.
| opentelemetry::nostd::shared_ptr< | ||
| opentelemetry::metrics::MeterProvider> const& provider, | ||
| std::string server_address) | ||
| : client_version_(SemanticVersionString()), |
| 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()); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16714 +/- ##
==========================================
+ Coverage 92.78% 92.79% +0.01%
==========================================
Files 2277 2279 +2
Lines 228147 228265 +118
==========================================
+ Hits 211696 211829 +133
+ Misses 16451 16436 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
902964c to
85cd0d7
Compare
85cd0d7 to
5090454
Compare
| /// Labels for recording a failed attempt that did not reach the server | ||
| /// (`gcp.storage.client.server.unreached`). | ||
| struct ServerUnreachedLabels { | ||
| std::string_view rpc_system; |
There was a problem hiding this comment.
Same point as my comment on #16713: rpc_system accepts any string here, while AttemptMetrics fixes "grpc" and "http" inside per-transport methods. Would it make sense to split this into RecordGrpcServerUnreached() and RecordHttpServerUnreached() (or take an enum class), so callers cannot pass an arbitrary value?
There was a problem hiding this comment.
Split RecordServerUnreached into RecordGrpcServerUnreached and RecordHttpServerUnreached and removed rpc_system from ServerUnreachedLabels.
Replied by cpriti-o11y-agent
| struct ServerUnreachedLabels { | ||
| std::string_view rpc_system; | ||
| std::string_view operation; | ||
| std::string_view network_path; |
There was a problem hiding this comment.
network_path comes before error_type here, while GrpcAttemptLabels and HttpAttemptLabels list error_type first. All of these fields are std::string_view, so a caller filling both structs for one attempt can swap the two values without a compile error. Would it make sense to keep the same relative order as the attempt labels?
There was a problem hiding this comment.
Reordered ServerUnreachedLabels to {operation, error_type, network_path} so it matches GrpcAttemptLabels and HttpAttemptLabels.
Replied by cpriti-o11y-agent
| using CounterPtr = opentelemetry::nostd::unique_ptr< | ||
| opentelemetry::metrics::Counter<std::uint64_t>>; | ||
|
|
||
| std::map<std::string, std::string> ExtractStringAttrs( |
There was a problem hiding this comment.
Same point as my comment on #16712: ExtractStringAttrs() here is another verbatim copy of the helper in operation_metrics_test.cc. Could this test use whichever shared location that thread settles on?
| using Attr = std::pair<opentelemetry::nostd::string_view, | ||
| opentelemetry::common::AttributeValue>; | ||
|
|
||
| opentelemetry::nostd::string_view ToNostd(std::string_view sv) { |
There was a problem hiding this comment.
Same point as my comment on #16712: ToNostd and SemanticVersionString are now in three places, here, operation_metrics.cc and attempt_metrics.cc.
| opentelemetry::metrics::MeterProvider> const& provider, | ||
| std::string server_address); | ||
|
|
||
| void RecordServerUnreached(ServerUnreachedLabels const& labels, |
There was a problem hiding this comment.
RecordServerUnreached does not say whether to call it when the client cannot tell if the server was reached, such as a client-side timeout or a cancellation. The counter's meaning depends on that, and the instrument description (Number of failed requests that did not reach Google Cloud Storage.) does not settle it either.
There was a problem hiding this comment.
Updated the method doc comments and counter description to state that callers only invoke this for proven pre-response failures (such as DNS, TLS, connection, or auth errors) and not for ambiguous aborts like timeouts or cancellations.
Replied by cpriti-o11y-agent
| 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()); | ||
| } |
There was a problem hiding this comment.
Same point as my reply on #16712: I would keep SemanticVersionString() here. version_string() returns v<major>.<minor>.<patch> plus any pre-release and build metadata, so gcp.client.version would no longer match what OperationMetrics and AttemptMetrics emit.
Adds the internal
ServerUnreachedMetricsrecorder for thegcp.storage.client.server.unreachedOpenTelemetry 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) plusrpc.system.name,gcp.storage.operation,network.path, anderror.type, propagating the explicitopentelemetry::context::Contextand 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