25 #include <seastar/core/sstring.hh>
26 #include <seastar/core/shared_ptr.hh>
28 #include <boost/lexical_cast.hpp>
30 #include <seastar/core/metrics_types.hh>
31 #include <seastar/util/std-compat.hh>
125 description(sstring s = sstring()) : _s(std::move(s))
127 const sstring& str()
const {
173 const sstring
key()
const {
215 explicit label(
const sstring& key) : key(key) {
253 enum class data_type : uint8_t {
267 std::variant<double, histogram> u;
269 data_type type()
const {
274 return std::get<double>(u);
277 uint64_t ui()
const {
278 return std::get<double>(u);
282 return std::get<double>(u);
286 : _type(data_type::GAUGE) {
290 u(std::move(h)), _type(t) {
309 return std::get<histogram>(u);
326 std::map<sstring, sstring> labels;
335 std::vector<label_instance> labels);
351 template<
typename T,
typename En = std::true_type>
355 struct is_callable<T, typename std::integral_constant<bool, !std::is_void<typename std::result_of<T()>::type>::value>::type> :
public std::true_type {
359 struct is_callable<T, typename std::enable_if<std::is_fundamental<T>::value, std::true_type>::type> :
public std::false_type {
362 template<typename T, typename = std::enable_if_t<is_callable<T>::value>>
363 metric_function make_function(T val, data_type dt) {
369 template<typename T, typename = std::enable_if_t<!is_callable<T>::value>>
370 metric_function make_function(T& val, data_type dt) {
372 return metric_value(val, dt);
377 extern const bool metric_disabled;
379 extern label shard_label;
395 return {name, {impl::data_type::GAUGE,
"gauge"}, make_function(std::forward<T>(val), impl::data_type::GAUGE), d, labels};
406 return {name, {impl::data_type::GAUGE,
"gauge"}, make_function(std::forward<T>(val), impl::data_type::GAUGE), d, {}};
416 description d, std::vector<label_instance> labels, T&& val) {
417 return {name, {impl::data_type::GAUGE,
"gauge"}, make_function(std::forward<T>(val), impl::data_type::GAUGE), d, labels};
432 return {name, {impl::data_type::DERIVE,
"derive"}, make_function(std::forward<T>(val), impl::data_type::DERIVE), d, labels};
447 return {name, {impl::data_type::DERIVE,
"derive"}, make_function(std::forward<T>(val), impl::data_type::DERIVE), d, {}};
462 return {name, {impl::data_type::DERIVE,
"derive"}, make_function(std::forward<T>(val), impl::data_type::DERIVE), d, labels};
476 return {name, {impl::data_type::COUNTER,
"counter"}, make_function(std::forward<T>(val), impl::data_type::COUNTER), d, labels};
488 return {name, {impl::data_type::ABSOLUTE,
"absolute"}, make_function(std::forward<T>(val), impl::data_type::ABSOLUTE), d, labels};
500 return {name, {impl::data_type::HISTOGRAM,
"histogram"}, make_function(std::forward<T>(val), impl::data_type::HISTOGRAM), d, labels};
511 description d, std::vector<label_instance> labels, T&& val) {
512 return {name, {impl::data_type::HISTOGRAM,
"histogram"}, make_function(std::forward<T>(val), impl::data_type::HISTOGRAM), d, labels};
525 return {name, {impl::data_type::HISTOGRAM,
"histogram"}, make_function(std::forward<T>(val), impl::data_type::HISTOGRAM), d, {}};
540 return make_derive(name, std::forward<T>(val), d, labels).set_type(
"total_bytes");
554 return make_derive(name, std::forward<T>(val), d, labels).set_type(
"bytes");
568 return make_gauge(name, std::forward<T>(val), d, labels).set_type(
"queue_length");
582 return make_derive(name, std::forward<T>(val), d, labels).set_type(
"total_operations");