移动 g_user_metric_label_count位置,避免循环引用 (#800)
This commit is contained in:
parent
cc10dbbe5b
commit
8ae2183ebe
|
@ -2,12 +2,15 @@
|
|||
#include <thread>
|
||||
|
||||
#include "metric.hpp"
|
||||
#include "thread_local_value.hpp"
|
||||
#include "ylt/util/map_sharded.hpp"
|
||||
|
||||
namespace ylt::metric {
|
||||
|
||||
class dynamic_metric : public metric_t {
|
||||
public:
|
||||
static inline auto g_user_metric_label_count =
|
||||
new thread_local_value<int64_t>(std::thread::hardware_concurrency());
|
||||
using metric_t::metric_t;
|
||||
};
|
||||
|
||||
|
@ -124,4 +127,4 @@ class dynamic_metric_impl : public dynamic_metric {
|
|||
my_hash<137>>
|
||||
map_{std::min<unsigned>(128u, std::thread::hardware_concurrency())};
|
||||
};
|
||||
} // namespace ylt::metric
|
||||
} // namespace ylt::metric
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "async_simple/coro/Lazy.h"
|
||||
#include "async_simple/coro/SyncAwait.h"
|
||||
#include "cinatra/cinatra_log_wrapper.hpp"
|
||||
#include "thread_local_value.hpp"
|
||||
#if __has_include("ylt/coro_io/coro_io.hpp")
|
||||
#include "ylt/coro_io/coro_io.hpp"
|
||||
#else
|
||||
|
@ -52,8 +51,7 @@ struct metric_filter_options {
|
|||
class metric_t {
|
||||
public:
|
||||
static inline std::atomic<int64_t> g_user_metric_count = 0;
|
||||
static inline auto g_user_metric_label_count =
|
||||
new thread_local_value<int64_t>(std::thread::hardware_concurrency());
|
||||
|
||||
metric_t() = default;
|
||||
metric_t(MetricType type, std::string name, std::string help)
|
||||
: type_(type),
|
||||
|
|
|
@ -362,7 +362,8 @@ inline void stat_metric() {
|
|||
static auto user_metric_label_count =
|
||||
system_metric_manager::instance().get_metric_static<gauge_t>(
|
||||
"ylt_user_metric_labels");
|
||||
user_metric_label_count->update(metric_t::g_user_metric_label_count->value());
|
||||
user_metric_label_count->update(
|
||||
dynamic_metric::g_user_metric_label_count->value());
|
||||
}
|
||||
|
||||
inline void ylt_stat() {
|
||||
|
@ -451,4 +452,4 @@ inline bool start_system_metric() {
|
|||
return true;
|
||||
}
|
||||
} // namespace ylt::metric
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue