25#include <seastar/util/modules.hh>
26#include <seastar/core/sharded.hh>
28#include <boost/functional/hash.hpp>
44using labels_type = std::map<sstring, sstring>;
52struct hash<
seastar::metrics::impl::labels_type> {
53 using argument_type = seastar::metrics::impl::labels_type;
54 using result_type = ::std::size_t;
55 result_type operator()(argument_type
const& s)
const {
58 boost::hash_combine(h, std::hash<seastar::sstring>{}(i.second));
73struct metric_family_config;
87 size_t metrics_relabeled_due_to_collision;
109 labels_type labels = {})
110 : _group(std::move(group)), _name(
111 std::move(name)), _labels(labels) {
126 return _labels.at(shard_label.
name());
131 const labels_type& labels()
const {
134 labels_type& labels() {
137 sstring full_name()
const;
142 auto as_tuple()
const {
143 return std::tie(group_name(), instance_id(), name(), labels());
159 typedef ::std::size_t result_type;
162 result_type
const h1 ( std::hash<seastar::sstring>{}(s.group_name()) );
163 result_type
const h2 ( std::hash<seastar::sstring>{}(s.instance_id()) );
164 return h1 ^ (h2 << 1);
185 std::vector<std::string> aggregate_labels;
194 labels_type original_labels;
200using metrics_registration = std::vector<metric_id>;
203 metrics_registration _registration;
226 bool is_enabled()
const {
227 return _info.enabled;
230 void set_enabled(
bool b) {
234 _info.should_skip_when_empty = skip;
246 const metric_function& get_function()
const {
252using metric_instances = std::map<labels_type, register_ref>;
255 metric_instances _instances;
258 using iterator = metric_instances::iterator;
259 using const_iterator = metric_instances::const_iterator;
263 metric_family(
const metric_instances& instances) : _instances(instances) {
269 metric_family(metric_instances&& instances) : _instances(std::move(instances)) {
273 return _instances[l];
277 return _instances.at(l);
288 iterator find(
const labels_type& l) {
289 return _instances.find(l);
292 const_iterator find(
const labels_type& l)
const {
293 return _instances.find(l);
297 return _instances.begin();
300 const_iterator begin()
const {
301 return _instances.cbegin();
305 return _instances.end();
309 return _instances.empty();
312 iterator erase(const_iterator position) {
313 return _instances.erase(position);
316 const_iterator end()
const {
317 return _instances.cend();
320 uint32_t size()
const {
321 return _instances.size();
326using value_map = std::map<sstring, metric_family>;
328using metric_metadata_fifo = std::deque<metric_info>;
344 metric_metadata_fifo metrics;
347using value_vector = std::deque<metric_value>;
348using metric_metadata = std::vector<metric_family_metadata>;
349using metric_values = std::deque<value_vector>;
353 metric_values values;
361 value_map _value_map;
365 std::set<sstring> _labels;
366 std::vector<std::deque<metric_function>> _current_metrics;
367 std::vector<relabel_config> _relabel_configs;
368 std::vector<metric_family_config> _metric_family_configs;
370 value_map& get_value_map() {
374 const value_map& get_value_map()
const {
379 void remove_registration(
const metric_id&
id);
381 return make_ready_future<>();
383 const config& get_config()
const {
386 void set_config(
const config& c) {
392 std::vector<std::deque<metric_function>>& functions();
394 void update_metrics_if_needed();
400 const std::set<sstring>& get_labels()
const noexcept {
406 const std::vector<relabel_config>& get_relabel_configs()
const noexcept {
407 return _relabel_configs;
409 const std::vector<metric_family_config>& get_metric_family_configs()
const noexcept {
410 return _metric_family_configs;
413 void set_metric_family_configs(
const std::vector<metric_family_config>& metrics_config);
418const value_map& get_value_map();
425void unregister_metric(
const metric_id &
id);
502const std::vector<relabel_config>& get_relabel_configs();
521void set_metric_family_configs(
const std::vector<metric_family_config>& metrics_config);
527const std::vector<metric_family_config>& get_metric_family_configs();
Definition: sharded.hh:927
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Human-readable description of a metric/group.
Definition: metrics.hh:133
Definition: metrics_api.hh:254
Definition: metrics.hh:398
Definition: metrics_api.hh:202
Definition: metrics_api.hh:105
A helper class that used to return metrics value.
Definition: metrics.hh:294
Definition: metrics_api.hh:216
const sstring & name() const
returns the label name
Definition: metrics.hh:248
Definition: metrics_registration.hh:67
Definition: program-options.hh:292
sstring metric_type_def
Definition: metrics.hh:113
sstring metric_name_type
Definition: metrics.hh:114
sstring instance_id_type
Definition: metrics.hh:115
header for metrics creation.
std::unique_ptr< metric_groups_def > create_metric_groups()
initialize metric group
holds the implementation parts of the metrics layer, do not use directly.
sstring group_name_type
Definition: metrics_registration.hh:64
future configure(const options &opts)
set the metrics configuration
future< metric_relabeling_result > set_relabel_configs(const std::vector< relabel_config > &relabel_configs)
Perform relabeling and operation on metrics dynamically.
result of metric relabeling
Definition: metrics_api.hh:86
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: metrics_api.hh:356
holds metadata information of a metric family
Definition: metrics_api.hh:180
holds metric metadata
Definition: metrics_api.hh:192
Definition: metrics.hh:369
Definition: metrics_api.hh:351
Metrics configuration options.
Definition: metrics_api.hh:438
program_options::value< std::string > metrics_hostname
The hostname used by the metrics.
Definition: metrics_api.hh:442