This is an automated email from the ASF dual-hosted git repository. wangdan pushed a commit to branch migrate-metrics-dev in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
commit 0c293ceb789ef0b205091511023ce2868c73d1e6 Author: Dan Wang <[email protected]> AuthorDate: Thu Jun 1 11:05:00 2023 +0800 feat(new_metrics): migrate metrics for failure detector (#1502) https://github.com/apache/incubator-pegasus/issues/1501 The only server-level metric of failure detector is migrated to the new framework, i.e. the number of failed beacons sent by failure detector. --- src/failure_detector/failure_detector.cpp | 17 ++++++++--------- src/failure_detector/failure_detector.h | 4 ++-- src/utils/metrics.h | 3 ++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/failure_detector/failure_detector.cpp b/src/failure_detector/failure_detector.cpp index c682fe170..20145b2b7 100644 --- a/src/failure_detector/failure_detector.cpp +++ b/src/failure_detector/failure_detector.cpp @@ -35,7 +35,6 @@ #include "failure_detector/fd.code.definition.h" #include "fd_types.h" -#include "perf_counter/perf_counter.h" #include "runtime/api_layer1.h" #include "runtime/serverlet.h" #include "runtime/task/async_calls.h" @@ -44,22 +43,22 @@ #include "utils/command_manager.h" #include "utils/fmt_logging.h" #include "utils/process_utils.h" +#include "utils/string_view.h" + +METRIC_DEFINE_counter(server, + beacon_failed_count, + dsn::metric_unit::kBeacons, + "The number of failed beacons sent by failure detector"); namespace dsn { namespace fd { -failure_detector::failure_detector() +failure_detector::failure_detector() : METRIC_VAR_INIT_server(beacon_failed_count) { dsn::threadpool_code pool = task_spec::get(LPC_BEACON_CHECK.code())->pool_code; task_spec::get(RPC_FD_FAILURE_DETECTOR_PING.code())->pool_code = pool; task_spec::get(RPC_FD_FAILURE_DETECTOR_PING_ACK.code())->pool_code = pool; - _recent_beacon_fail_count.init_app_counter( - "eon.failure_detector", - "recent_beacon_fail_count", - COUNTER_TYPE_VOLATILE_NUMBER, - "failure detector beacon fail count in the recent period"); - _is_started = false; } @@ -423,7 +422,7 @@ bool failure_detector::end_ping_internal(::dsn::error_code err, const beacon_ack node, _beacon_timeout_milliseconds, err); - _recent_beacon_fail_count->increment(); + METRIC_VAR_INCREMENT(beacon_failed_count); } master_map::iterator itr = _masters.find(node); diff --git a/src/failure_detector/failure_detector.h b/src/failure_detector/failure_detector.h index 85186ac65..190169c2c 100644 --- a/src/failure_detector/failure_detector.h +++ b/src/failure_detector/failure_detector.h @@ -70,12 +70,12 @@ #include "failure_detector/fd.client.h" #include "failure_detector/fd.server.h" -#include "perf_counter/perf_counter_wrapper.h" #include "runtime/rpc/rpc_address.h" #include "runtime/task/task.h" #include "runtime/task/task_code.h" #include "runtime/task/task_tracker.h" #include "utils/error_code.h" +#include "utils/metrics.h" #include "utils/threadpool_code.h" #include "utils/zlocks.h" @@ -238,7 +238,7 @@ private: bool _use_allow_list; allow_list _allow_list; - perf_counter_wrapper _recent_beacon_fail_count; + METRIC_VAR_DECLARE_counter(beacon_failed_count); std::unique_ptr<command_deregister> _get_allow_list; diff --git a/src/utils/metrics.h b/src/utils/metrics.h index b474538e9..979c8274d 100644 --- a/src/utils/metrics.h +++ b/src/utils/metrics.h @@ -698,7 +698,8 @@ ENUM_END(metric_type) DEF(Backups) \ DEF(FileLoads) \ DEF(FileUploads) \ - DEF(BulkLoads) + DEF(BulkLoads) \ + DEF(Beacons) enum class metric_unit : size_t { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
