From 90b729d29d8411f5f93b132c7193adee7750eee0 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Mon, 19 Dec 2016 13:00:57 +0200 Subject: [PATCH] http: Move metrics registration to the metrics layer This changes the http metrics registration to use the metrics registration instead of the collectd. This is a resubmission of the patch with the updated API. Message-Id: <1482145257-31726-1-git-send-email-amnon@scylladb.com> --- http/httpd.cc | 26 ++++++++------------------ http/httpd.hh | 4 ++-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/http/httpd.cc b/http/httpd.cc index 5d99ace34b8..be9465ba674 100644 --- a/http/httpd.cc +++ b/http/httpd.cc @@ -26,7 +26,7 @@ #include "core/distributed.hh" #include "core/queue.hh" #include "core/future-util.hh" -#include "core/scollectd.hh" +#include "core/metrics.hh" #include #include #include @@ -41,22 +41,12 @@ using namespace std::chrono_literals; namespace httpd { http_stats::http_stats(http_server& server) - : _regs{ - scollectd::add_polled_metric( - scollectd::type_instance_id("httpd", scollectd::per_cpu_plugin_instance, - "connections", "http-connections"), - scollectd::make_typed(scollectd::data_type::DERIVE, - [&server] { return server.total_connections(); })), - scollectd::add_polled_metric( - scollectd::type_instance_id("httpd", scollectd::per_cpu_plugin_instance, - "current_connections", "current"), - scollectd::make_typed(scollectd::data_type::GAUGE, - [&server] { return server.current_connections(); })), - scollectd::add_polled_metric( - scollectd::type_instance_id("httpd", scollectd::per_cpu_plugin_instance, - "http_requests", "served"), - scollectd::make_typed(scollectd::data_type::DERIVE, - [&server] { return server.requests_served(); })), - } { + { + namespace sm = seastar::metrics; + _metric_groups.add_group("httpd", { + sm::make_derive("connections_total", [&server] { return server.total_connections(); }, sm::description("The total number of connections opened")), + sm::make_gauge("connections_current", [&server] { return server.current_connections(); }, sm::description("The current number of open connections")), + sm::make_derive("requests_served", [&server] { return server.requests_served(); }, sm::description("The total number of http requests served")) + }); } } diff --git a/http/httpd.hh b/http/httpd.hh index 92acb2776cd..78954c5637a 100644 --- a/http/httpd.hh +++ b/http/httpd.hh @@ -32,7 +32,7 @@ #include "core/distributed.hh" #include "core/queue.hh" #include "core/future-util.hh" -#include "core/scollectd.hh" +#include "core/metrics_registration.hh" #include #include #include @@ -53,7 +53,7 @@ class http_stats; using namespace std::chrono_literals; class http_stats { - scollectd::registrations _regs; + seastar::metrics::metric_groups _metric_groups; public: http_stats(http_server& server); };