Seastar
High performance C++ framework for concurrent servers
|
Implementation of rudimentary collectd data gathering.
Usage is hopefully straight forward. Though, feel free to read https://collectd.org/wiki/index.php/Naming_schema for an explanation on the naming model.
Typically, you'll add values something like:
scollectd::type_instance_id typ("<pluginname>", "<instance_name>", "<type_name>", "<instance_name>"); scollectd::add_polled_metric(typ, [<metric var> | scollectd::make_typed(<data_type>, <metric_var>) [, ...]);
Where <pluginname>
would be the overall 'module', e.g. "cpu" <instance_name>
-> optional distinguisher between plugin instances. For cpu, the built-in scollectd::per_cpu_plugin_instance constant is a good choice, i.e. 0->N cpu. If there are no instances (e.g. only one), empty constant is appropriate (none) <type_name>
is the 'type' of metric collected, for ex. "usage" (cpu/0/usage) <type_instance>
is a distinguisher for metric parts of the type, e.g. "idle", "user", "kernel" -> cpu/0/usage/idle | cpu/0/usage/user | cpu/0/usage/kernel
Each type instance can bind an arbitrary number of values, ech representing some aspect in turn of the instance. The structure and interpretation is up to the producer/consumer
There is a single "scollectd" instance per cpu, and values should be bound locally to this cpu. Polling is done at a frequency set in the seastar config (def once per s), and all registered values will be sent via UDP packages to the destination host(s)
Note that the tuple { plugin, plugin_instance, type, type_instance } is considered a unique ID for a value registration, so using the same tuple twice will remove the previously registered values.
Values can be unregistered at any time, though they must be so on the same thread/cpu as they we're registered. The "registration" achor type provides RAII style value unregistration semantics.
Classes | |
struct | data_type_for |
struct | data_type_for< T, std::enable_if_t< is_callable< T >::value, void > > |
struct | data_type_for< T, std::enable_if_t< std::is_floating_point_v< T >, void > > |
struct | data_type_for< T, std::enable_if_t< std::is_integral_v< T > &&std::is_unsigned_v< T >, void > > |
struct | data_type_for< typed< T > > |
struct | is_callable |
struct | is_callable< T, std::enable_if_t< std::is_fundamental_v< T >, void > > |
struct | is_callable< T, std::enable_if_t<!std::is_void_v< std::invoke_result_t< T > >, void > > |
struct | options |
class | percpu_plugin_instance_metrics |
class | plugin_instance_metrics |
struct | registration |
class | registrations |
class | type_instance_id |
struct | typed |
struct | typed_value |
struct | typed_value_impl |
class | value |
class | value< typed< T > > |
class | value_list |
class | values_impl |
Typedefs | |
using | data_type = seastar::metrics::impl::data_type |
using | plugin_id = seastar::metrics::group_name_type |
using | plugin_instance_id = seastar::metrics::instance_id_type |
using | type_id = seastar::metrics::metric_type_def |
using | type_instance = seastar::metrics::metric_name_type |
using | description = seastar::metrics::description |
typedef typed_value_impl< known_type::total_bytes > | total_bytes |
typedef typed_value_impl< known_type::total_connections > | total_connections |
typedef typed_value_impl< known_type::total_objects > | total_objects |
typedef typed_value_impl< known_type::total_operations > | total_operations |
typedef typed_value_impl< known_type::total_requests > | total_requests |
typedef typed_value_impl< known_type::total_sessions > | total_sessions |
typedef typed_value_impl< known_type::total_threads > | total_threads |
typedef typed_value_impl< known_type::total_time_in_ms > | total_time_in_ms |
typedef typed_value_impl< known_type::total_values > | total_values |
typedef typed_value_impl< known_type::queue_length > | queue_length |
typedef typed_value_impl< known_type::counter > | counter |
typedef typed_value_impl< known_type::count > | count |
typedef typed_value_impl< known_type::gauge > | gauge |
typedef std::function< void()> | notify_function |
using | collectd_value = seastar::metrics::impl::metric_value |
Functions | |
template<typename T > | |
typed< T > | make_typed (data_type type, T &&t) |
type_id | type_id_for (known_type) |
void | configure (const options &) |
void | remove_polled_metric (const type_instance_id &) |
void | add_polled (const type_instance_id &, const shared_ptr< value_list > &, bool enabled=true) |
template<typename... _Args> | |
static auto | make_type_instance (description d, _Args &&... args) -> values_impl< decltype(value< _Args >(std::forward< _Args >(args)))... > |
template<typename ... _Args> | |
static type_instance_id | add_polled_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, _Args &&... args) |
template<typename ... _Args> | |
static type_instance_id | add_polled_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, description d, _Args &&... args) |
template<typename ... _Args> | |
static future | send_explicit_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, _Args &&... args) |
template<typename ... _Args> | |
static notify_function | create_explicit_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, _Args &&... args) |
seastar::metrics::impl::metric_id | to_metrics_id (const type_instance_id &id) |
template<typename Arg > | |
static type_instance_id | add_polled_metric (const type_instance_id &id, description d, Arg &&arg, bool enabled=true) |
template<typename Arg > | |
static type_instance_id | add_polled_metric (const type_instance_id &id, Arg &&arg) |
template<typename Args > | |
static type_instance_id | add_disabled_polled_metric (const type_instance_id &id, description d, Args &&arg) |
template<typename Args > | |
static type_instance_id | add_disabled_polled_metric (const type_instance_id &id, Args &&args) |
template<typename ... Args> | |
static type_instance_id | add_disabled_polled_metric (const type_instance_id &id, Args &&... args) |
template<typename ... _Args> | |
static future | send_explicit_metric (const type_instance_id &id, _Args &&... args) |
template<typename ... _Args> | |
static notify_function | create_explicit_metric (const type_instance_id &id, _Args &&... args) |
future | send_notification (const type_instance_id &id, const sstring &msg) |
std::vector< collectd_value > | get_collectd_value (const scollectd::type_instance_id &id) |
std::vector< scollectd::type_instance_id > | get_collectd_ids () |
sstring | get_collectd_description_str (const scollectd::type_instance_id &) |
bool | is_enabled (const scollectd::type_instance_id &id) |
void | enable (const scollectd::type_instance_id &id, bool enable) |
metrics::impl::value_map | get_value_map () |
Variables | |
seastar::logger | logger |
static constexpr unsigned | max_collectd_field_text_len = 63 |
const plugin_instance_id | per_cpu_plugin_instance |
struct seastar::scollectd::is_callable |
typedef typed_value_impl<known_type::total_bytes> seastar::scollectd::total_bytes |
Some typedefs for common used types. Feel free to add.
|
static |
|
static |
|
static |
|
static |
|
static |
void seastar::scollectd::enable | ( | const scollectd::type_instance_id & | id, |
bool | enable | ||
) |
Enable or disable collectd metrics on local instance
id | - the metric to enable or disable |
enable | - should the collectd metrics be enable or disable |