Commit e8226c48 authored by zhujiashun's avatar zhujiashun

Make SummaryItem::{latency_avg, count} be int64_t

parent 16b9bc78
...@@ -62,8 +62,8 @@ private: ...@@ -62,8 +62,8 @@ private:
struct SummaryItems { struct SummaryItems {
std::string latency_percentiles[NPERCENTILES]; std::string latency_percentiles[NPERCENTILES];
std::string latency_avg; int64_t latency_avg;
std::string count; int64_t count;
std::string metric_name; std::string metric_name;
bool IsComplete() const { return !metric_name.empty(); } bool IsComplete() const { return !metric_name.empty(); }
...@@ -103,6 +103,7 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& ...@@ -103,6 +103,7 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece&
butil::string_printf("_latency_%d", (int)bvar::FLAGS_bvar_latency_p3), butil::string_printf("_latency_%d", (int)bvar::FLAGS_bvar_latency_p3),
"_latency_999", "_latency_9999", "_max_latency" "_latency_999", "_latency_9999", "_max_latency"
}; };
std::string desc_str = desc.as_string();
CHECK(NPERCENTILES == arraysize(latency_names)); CHECK(NPERCENTILES == arraysize(latency_names));
butil::StringPiece metric_name(name); butil::StringPiece metric_name(name);
for (int i = 0; i < NPERCENTILES; ++i) { for (int i = 0; i < NPERCENTILES; ++i) {
...@@ -111,7 +112,7 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& ...@@ -111,7 +112,7 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece&
} }
metric_name.remove_suffix(latency_names[i].size()); metric_name.remove_suffix(latency_names[i].size());
SummaryItems* si = &_m[metric_name.as_string()]; SummaryItems* si = &_m[metric_name.as_string()];
si->latency_percentiles[i] = desc.as_string(); si->latency_percentiles[i] = desc_str;
if (i == NPERCENTILES - 1) { if (i == NPERCENTILES - 1) {
// '_max_latency' is the last suffix name that appear in the sorted bvar // '_max_latency' is the last suffix name that appear in the sorted bvar
// list, which means all related percentiles have been gathered and we are // list, which means all related percentiles have been gathered and we are
...@@ -124,13 +125,13 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& ...@@ -124,13 +125,13 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece&
if (metric_name.ends_with("_latency")) { if (metric_name.ends_with("_latency")) {
metric_name.remove_suffix(8); metric_name.remove_suffix(8);
SummaryItems* si = &_m[metric_name.as_string()]; SummaryItems* si = &_m[metric_name.as_string()];
si->latency_avg = desc.as_string(); si->latency_avg = strtoll(desc_str.data(), NULL, 10);
return si; return si;
} }
if (metric_name.ends_with("_count")) { if (metric_name.ends_with("_count")) {
metric_name.remove_suffix(6); metric_name.remove_suffix(6);
SummaryItems* si = &_m[metric_name.as_string()]; SummaryItems* si = &_m[metric_name.as_string()];
si->count = desc.as_string(); si->count = strtoll(desc_str.data(), NULL, 10);
return si; return si;
} }
return NULL; return NULL;
...@@ -169,8 +170,7 @@ bool PrometheusMetricsDumper::DumpLatencyRecorderSuffix( ...@@ -169,8 +170,7 @@ bool PrometheusMetricsDumper::DumpLatencyRecorderSuffix(
<< si->metric_name << "_sum " << si->metric_name << "_sum "
// There is no sum of latency in bvar output, just use // There is no sum of latency in bvar output, just use
// average * count as approximation // average * count as approximation
<< strtoll(si->latency_avg.data(), NULL, 10) * << si->latency_avg * si->count << '\n'
strtoll(si->count.data(), NULL, 10) << '\n'
<< si->metric_name << "_count " << si->count << '\n'; << si->metric_name << "_count " << si->count << '\n';
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment