diff --git a/include/seastar/core/metrics_api.hh b/include/seastar/core/metrics_api.hh index 5fa58d6014f..87f0eb948d7 100644 --- a/include/seastar/core/metrics_api.hh +++ b/include/seastar/core/metrics_api.hh @@ -190,7 +190,7 @@ class registered_metric { metric_function _f; shared_ptr _impl; public: - registered_metric(metric_id id, metric_function f, bool enabled=true); + registered_metric(metric_id id, metric_function f, bool enabled=true, int handle=default_handle()); virtual ~registered_metric() {} virtual metric_value operator()() const { return _f(); @@ -365,14 +365,15 @@ public: } }; -const value_map& get_value_map(); +const value_map& get_value_map(int handle = default_handle()); using values_reference = shared_ptr; -foreign_ptr get_values(); +foreign_ptr get_values(int handle = default_handle()); shared_ptr get_local_impl(int handle = default_handle()); -void unregister_metric(const metric_id & id); + +void unregister_metric(const metric_id & id, int handle = default_handle()); /*! * \brief initialize metric group diff --git a/src/core/metrics.cc b/src/core/metrics.cc index 02cf0f66df5..a60bd87dd70 100644 --- a/src/core/metrics.cc +++ b/src/core/metrics.cc @@ -121,8 +121,8 @@ bool label_instance::operator!=(const label_instance& id2) const { label shard_label("shard"); namespace impl { -registered_metric::registered_metric(metric_id id, metric_function f, bool enabled) : - _f(f), _impl(get_local_impl()) { +registered_metric::registered_metric(metric_id id, metric_function f, bool enabled, int handle) : + _f(f), _impl(get_local_impl(handle)) { _info.enabled = enabled; _info.id = id; } @@ -262,20 +262,20 @@ void impl::remove_registration(const metric_id& id) { } } -void unregister_metric(const metric_id & id) { - get_local_impl()->remove_registration(id); +void unregister_metric(const metric_id & id, int handle) { + get_local_impl(handle)->remove_registration(id); } -const value_map& get_value_map() { - return get_local_impl()->get_value_map(); +const value_map& get_value_map(int handle) { + return get_local_impl(handle)->get_value_map(); } -foreign_ptr get_values() { +foreign_ptr get_values(int handle) { shared_ptr res_ref = ::seastar::make_shared(); auto& res = *(res_ref.get()); auto& mv = res.values; - res.metadata = get_local_impl()->metadata(); - auto & functions = get_local_impl()->functions(); + res.metadata = get_local_impl(handle)->metadata(); + auto & functions = get_local_impl(handle)->functions(); mv.reserve(functions.size()); for (auto&& i : functions) { value_vector values;