Skip to content

Commit

Permalink
http: Move metrics registration to the metrics layer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
amnonh authored and avikivity committed Dec 21, 2016
1 parent 68b3548 commit 90b729d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
26 changes: 8 additions & 18 deletions http/httpd.cc
Expand Up @@ -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 <iostream>
#include <algorithm>
#include <unordered_map>
Expand All @@ -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"))
});
}
}
4 changes: 2 additions & 2 deletions http/httpd.hh
Expand Up @@ -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 <iostream>
#include <algorithm>
#include <unordered_map>
Expand All @@ -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);
};
Expand Down

0 comments on commit 90b729d

Please sign in to comment.