Skip to content

Commit

Permalink
[metric] refact summary with better algorithm (#767)
Browse files Browse the repository at this point in the history
* [metric] refact summary with better algorithm

* fix msvc
  • Loading branch information
poor-circle committed Sep 9, 2024
1 parent 7207de8 commit 81a1866
Show file tree
Hide file tree
Showing 8 changed files with 646 additions and 679 deletions.
175 changes: 0 additions & 175 deletions include/ylt/metric/detail/ckms_quantiles.hpp

This file was deleted.

52 changes: 0 additions & 52 deletions include/ylt/metric/detail/time_window_quantiles.hpp

This file was deleted.

13 changes: 0 additions & 13 deletions include/ylt/metric/metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,6 @@ class metric_t {
virtual void serialize_to_json(std::string& str) {}
#endif

// only for summary
virtual async_simple::coro::Lazy<void> serialize_async(std::string& out) {
co_return;
}

#ifdef CINATRA_ENABLE_METRIC_JSON
// only for summary
virtual async_simple::coro::Lazy<void> serialize_to_json_async(
std::string& out) {
co_return;
}
#endif

template <typename T>
T* as() {
return dynamic_cast<T*>(this);
Expand Down
16 changes: 2 additions & 14 deletions include/ylt/metric/metric_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ class manager_helper {
const std::vector<std::shared_ptr<metric_t>>& metrics) {
std::string str;
for (auto& m : metrics) {
if (m->metric_type() == MetricType::Summary) {
async_simple::coro::syncAwait(m->serialize_async(str));
}
else {
m->serialize(str);
}
m->serialize(str);
}

return str;
}

Expand All @@ -49,13 +43,7 @@ class manager_helper {
str.append("[");
for (auto& m : metrics) {
size_t start = str.size();
if (m->metric_type() == MetricType::Summary) {
async_simple::coro::syncAwait(m->serialize_to_json_async(str));
}
else {
m->serialize_to_json(str);
}

m->serialize_to_json(str);
if (str.size() > start)
str.append(",");
}
Expand Down
Loading

0 comments on commit 81a1866

Please sign in to comment.