Skip to content

Commit

Permalink
collectd: Register metrics using the metrics layer
Browse files Browse the repository at this point in the history
This patch changes the collectd implementation to register and hold its
metrics using the metrics layer.

Signed-off-by: Amnon Heiman <[email protected]>
  • Loading branch information
amnonh committed Mar 28, 2017
1 parent dd5ffb9 commit 149e797
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
2 changes: 1 addition & 1 deletion core/scollectd-impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private:
const value_list_map& values() const {
return seastar::metrics::impl::get_value_map();
}
registrations _regs;
seastar::metrics::metric_groups _metrics;
};

impl & get_impl();
Expand Down
41 changes: 11 additions & 30 deletions core/scollectd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,41 +345,22 @@ void impl::start(const sstring & host, const ipv4_addr & addr, const duration pe
_timer.set_callback(std::bind(&impl::run, this));

// dogfood ourselves
_regs = {
namespace sm = seastar::metrics;

_metrics.add_group("scollectd", {
// total_bytes value:DERIVE:0:U
add_polled_metric(
type_instance_id("scollectd", per_cpu_plugin_instance,
"total_bytes", "sent"),
make_typed(data_type::DERIVE, _bytes)),
sm::make_derive("total_bytes_sent", sm::description("total bytes sent"), _bytes),
// total_requests value:DERIVE:0:U
add_polled_metric(
type_instance_id("scollectd", per_cpu_plugin_instance,
"total_requests"),
make_typed(data_type::DERIVE, _num_packets)
),
sm::make_derive("total_requests", sm::description("total requests"), _num_packets),
// latency value:GAUGE:0:U
add_polled_metric(
type_instance_id("scollectd", per_cpu_plugin_instance,
"latency"), make_typed(data_type::GAUGE, _avg)),
sm::make_gauge("latency", sm::description("avrage latency"), _avg),
// total_time_in_ms value:DERIVE:0:U
add_polled_metric(
type_instance_id("scollectd", per_cpu_plugin_instance,
"total_time_in_ms"),
make_typed(data_type::DERIVE, _millis)
),
sm::make_derive("total_time_in_ms", sm::description("total time in milliseconds"), _millis),
// total_values value:DERIVE:0:U
add_polled_metric(
type_instance_id("scollectd", per_cpu_plugin_instance,
"total_values"),
make_typed(data_type::DERIVE, [this] {return values().size();})
),
sm::make_gauge("total_values", sm::description("current number of values reported"), [this] {return values().size();}),
// records value:GAUGE:0:U
add_polled_metric(
type_instance_id("scollectd", per_cpu_plugin_instance,
"records"),
make_typed(data_type::GAUGE, [this] {return values().size();})
),
};
sm::make_gauge("records", sm::description("number of records reported"), [this] {return values().size();}),
});

send_notification(
type_instance_id("scollectd", per_cpu_plugin_instance,
Expand All @@ -389,7 +370,7 @@ void impl::start(const sstring & host, const ipv4_addr & addr, const duration pe

void impl::stop() {
_timer.cancel();
_regs.clear();
_metrics.clear();
}


Expand Down

0 comments on commit 149e797

Please sign in to comment.