]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/src/core/metrics.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / seastar / src / core / metrics.cc
index 19cb16e3ff4c80b48e7fbba02802a07f2a473c85..af03cbec35c7c3b8a0b0964918e21000e04f8c3a 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <seastar/core/metrics.hh>
 #include <seastar/core/metrics_api.hh>
+#include <seastar/core/reactor.hh>
 #include <boost/range/algorithm.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/replace.hpp>
@@ -118,7 +119,6 @@ bool label_instance::operator!=(const label_instance& id2) const {
 }
 
 label shard_label("shard");
-label type_label("type");
 namespace impl {
 
 registered_metric::registered_metric(metric_id id, metric_function f, bool enabled) :
@@ -131,10 +131,10 @@ metric_value metric_value::operator+(const metric_value& c) {
     metric_value res(*this);
     switch (_type) {
     case data_type::HISTOGRAM:
-        compat::get<histogram>(res.u) += compat::get<histogram>(c.u);
+        std::get<histogram>(res.u) += std::get<histogram>(c.u);
         break;
     default:
-        compat::get<double>(res.u) += compat::get<double>(c.u);
+        std::get<double>(res.u) += std::get<double>(c.u);
         break;
     }
     return res;
@@ -154,9 +154,6 @@ metric_definition_impl::metric_definition_impl(
     if (labels.find(shard_label.name()) == labels.end()) {
         labels[shard_label.name()] = shard();
     }
-    if (labels.find(type_label.name()) == labels.end()) {
-        labels[type_label.name()] = type.type_name;
-    }
 }
 
 metric_definition_impl& metric_definition_impl::operator ()(bool _enabled) {
@@ -169,6 +166,11 @@ metric_definition_impl& metric_definition_impl::operator ()(const label_instance
     return *this;
 }
 
+metric_definition_impl& metric_definition_impl::set_type(const sstring& type_name) {
+    type.type_name = type_name;
+    return *this;
+}
+
 std::unique_ptr<metric_groups_def> create_metric_groups() {
     return  std::make_unique<metric_groups_impl>();
 }
@@ -183,7 +185,7 @@ metric_groups_impl& metric_groups_impl::add_metric(group_name_type name, const m
 
     metric_id id(name, md._impl->name, md._impl->labels);
 
-    get_local_impl()->add_registration(id, md._impl->type.base_type, md._impl->f, md._impl->d, md._impl->enabled);
+    get_local_impl()->add_registration(id, md._impl->type, md._impl->f, md._impl->d, md._impl->enabled);
 
     _registration.push_back(id);
     return *this;
@@ -274,7 +276,7 @@ foreign_ptr<values_reference> get_values() {
 
 instance_id_type shard() {
     if (engine_is_ready()) {
-        return to_sstring(engine().cpu_id());
+        return to_sstring(this_shard_id());
     }
 
     return sstring("0");
@@ -324,7 +326,7 @@ std::vector<std::vector<metric_function>>& impl::functions() {
     return _current_metrics;
 }
 
-void impl::add_registration(const metric_id& id, data_type type, metric_function f, const description& d, bool enabled) {
+void impl::add_registration(const metric_id& id, const metric_type& type, metric_function f, const description& d, bool enabled) {
     auto rm = ::seastar::make_shared<registered_metric>(id, f, enabled);
     sstring name = id.full_name();
     if (_value_map.find(name) != _value_map.end()) {
@@ -332,13 +334,14 @@ void impl::add_registration(const metric_id& id, data_type type, metric_function
         if (metric.find(id.labels()) != metric.end()) {
             throw double_registration("registering metrics twice for metrics: " + name);
         }
-        if (metric.info().type != type) {
+        if (metric.info().type != type.base_type) {
             throw std::runtime_error("registering metrics " + name + " registered with different type.");
         }
         metric[id.labels()] = rm;
     } else {
-        _value_map[name].info().type = type;
+        _value_map[name].info().type = type.base_type;
         _value_map[name].info().d = d;
+        _value_map[name].info().inherit_type = type.type_name;
         _value_map[name].info().name = id.full_name();
         _value_map[name][id.labels()] = rm;
     }