19 #ifndef GRPC_CORE_EXT_XDS_XDS_CLIENT_STATS_H
20 #define GRPC_CORE_EXT_XDS_XDS_CLIENT_STATS_H
27 #include "absl/strings/str_cat.h"
28 #include "absl/strings/str_format.h"
29 #include "absl/strings/string_view.h"
49 if (lhs ==
nullptr || rhs ==
nullptr)
return GPR_ICMP(lhs, rhs);
55 return (*
this)(lhs.
get(), rhs.
get());
65 return region_ == other.region_ && zone_ == other.zone_ &&
66 sub_zone_ == other.sub_zone_;
70 return !(*
this == other);
74 int cmp_result = region_.compare(other.region_);
75 if (cmp_result != 0)
return cmp_result;
76 cmp_result = zone_.compare(other.zone_);
77 if (cmp_result != 0)
return cmp_result;
78 return sub_zone_.compare(other.sub_zone_);
81 const std::string&
region()
const {
return region_; }
82 const std::string&
zone()
const {
return zone_; }
83 const std::string&
sub_zone()
const {
return sub_zone_; }
86 if (human_readable_string_.empty()) {
87 human_readable_string_ =
88 absl::StrFormat(
"{region=\"%s\", zone=\"%s\", sub_zone=\"%s\"}",
89 region_, zone_, sub_zone_);
91 return human_readable_string_;
97 std::string sub_zone_;
98 std::string human_readable_string_;
124 if (p.second != 0)
return false;
131 absl::string_view lrs_server_name,
144 absl::string_view lrs_server_name_;
145 absl::string_view cluster_name_;
146 absl::string_view eds_service_name_;
198 if (!p.second.IsZero())
return false;
205 absl::string_view lrs_server_name,
219 absl::string_view lrs_server_name_;
220 absl::string_view cluster_name_;
221 absl::string_view eds_service_name_;
225 Atomic<uint64_t> total_requests_in_progress_{0};
226 Atomic<uint64_t> total_error_requests_{0};
227 Atomic<uint64_t> total_issued_requests_{0};
233 Mutex backend_metrics_mu_;
234 std::map<std::string, BackendMetric> backend_metrics_
235 ABSL_GUARDED_BY(backend_metrics_mu_);
Definition: ref_counted.h:282
Definition: ref_counted_ptr.h:35
T * get() const
Definition: ref_counted_ptr.h:147
Definition: xds_client_stats.h:102
std::map< std::string, uint64_t > CategorizedDropsMap
Definition: xds_client_stats.h:106
void AddCallDropped(const std::string &category)
Definition: xds_client_stats.cc:88
~XdsClusterDropStats() override
Definition: xds_client_stats.cc:63
void AddUncategorizedDrops()
Definition: xds_client_stats.cc:84
Snapshot GetSnapshotAndReset()
Definition: xds_client_stats.cc:76
XdsClusterDropStats(RefCountedPtr< XdsClient > xds_client, absl::string_view lrs_server_name, absl::string_view cluster_name, absl::string_view eds_service_name)
Definition: xds_client_stats.cc:44
Definition: xds_client_stats.h:156
~XdsClusterLocalityStats() override
Definition: xds_client_stats.cc:119
XdsClusterLocalityStats(RefCountedPtr< XdsClient > xds_client, absl::string_view lrs_server_name, absl::string_view cluster_name, absl::string_view eds_service_name, RefCountedPtr< XdsLocalityName > name)
Definition: xds_client_stats.cc:97
void AddCallFinished(bool fail=false)
Definition: xds_client_stats.cc:152
Snapshot GetSnapshotAndReset()
Definition: xds_client_stats.cc:134
void AddCallStarted()
Definition: xds_client_stats.cc:147
Definition: xds_client_stats.h:44
const std::string & region() const
Definition: xds_client_stats.h:81
const std::string & sub_zone() const
Definition: xds_client_stats.h:83
XdsLocalityName(std::string region, std::string zone, std::string sub_zone)
Definition: xds_client_stats.h:59
const std::string & zone() const
Definition: xds_client_stats.h:82
bool operator==(const XdsLocalityName &other) const
Definition: xds_client_stats.h:64
int Compare(const XdsLocalityName &other) const
Definition: xds_client_stats.h:73
const std::string & AsHumanReadableString()
Definition: xds_client_stats.h:85
bool operator!=(const XdsLocalityName &other) const
Definition: xds_client_stats.h:69
Round Robin Policy.
Definition: backend_metric.cc:26
Definition: async_unary_call.h:398
Definition: xds_client_stats.h:107
Snapshot & operator+=(const Snapshot &other)
Definition: xds_client_stats.h:113
bool IsZero() const
Definition: xds_client_stats.h:121
CategorizedDropsMap categorized_drops
Definition: xds_client_stats.h:111
uint64_t uncategorized_drops
Definition: xds_client_stats.h:108
Definition: xds_client_stats.h:158
BackendMetric & operator+=(const BackendMetric &other)
Definition: xds_client_stats.h:162
uint64_t num_requests_finished_with_metric
Definition: xds_client_stats.h:159
double total_metric_value
Definition: xds_client_stats.h:160
bool IsZero() const
Definition: xds_client_stats.h:169
Definition: xds_client_stats.h:174
uint64_t total_error_requests
Definition: xds_client_stats.h:177
uint64_t total_requests_in_progress
Definition: xds_client_stats.h:176
std::map< std::string, BackendMetric > backend_metrics
Definition: xds_client_stats.h:179
bool IsZero() const
Definition: xds_client_stats.h:192
uint64_t total_successful_requests
Definition: xds_client_stats.h:175
uint64_t total_issued_requests
Definition: xds_client_stats.h:178
Snapshot & operator+=(const Snapshot &other)
Definition: xds_client_stats.h:181
Definition: xds_client_stats.h:46
bool operator()(const XdsLocalityName *lhs, const XdsLocalityName *rhs) const
Definition: xds_client_stats.h:47
bool operator()(const RefCountedPtr< XdsLocalityName > &lhs, const RefCountedPtr< XdsLocalityName > &rhs) const
Definition: xds_client_stats.h:53
#define GPR_ICMP(a, b)
Definition: useful.h:60
std::string eds_service_name
Definition: xds_cluster_resolver.cc:74
std::string cluster_name
Definition: xds_cluster_resolver.cc:66