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;
211 bool is_enabled()
const {
212 return _info.enabled;
215 void set_enabled(
bool b) {
219 _info.should_skip_when_empty = skip;
231 const metric_function& get_function()
const {
237using metric_instances = std::map<labels_type, register_ref>;
238using metrics_registration = std::vector<register_ref>;
241 metrics_registration _registration;
254 metric_instances _instances;
257 using iterator = metric_instances::iterator;
258 using const_iterator = metric_instances::const_iterator;
262 metric_family(
const metric_instances& instances) : _instances(instances) {
268 metric_family(metric_instances&& instances) : _instances(std::move(instances)) {
272 return _instances[l];
276 return _instances.at(l);
287 iterator find(
const labels_type& l) {
288 return _instances.find(l);
291 const_iterator find(
const labels_type& l)
const {
292 return _instances.find(l);
296 return _instances.begin();
299 const_iterator begin()
const {
300 return _instances.cbegin();
304 return _instances.end();
308 return _instances.empty();
311 iterator erase(const_iterator position) {
312 return _instances.erase(position);
315 const_iterator end()
const {
316 return _instances.cend();
319 uint32_t size()
const {
320 return _instances.size();
325using value_map = std::map<sstring, metric_family>;
327using metric_metadata_fifo = std::deque<metric_info>;
343 metric_metadata_fifo metrics;
346using value_vector = std::deque<metric_value>;
347using metric_metadata = std::vector<metric_family_metadata>;
348using metric_values = std::deque<value_vector>;
352 metric_values values;
360 value_map _value_map;
364 std::set<sstring> _labels;
365 std::vector<std::deque<metric_function>> _current_metrics;
366 std::vector<relabel_config> _relabel_configs;
367 std::vector<metric_family_config> _metric_family_configs;
369 value_map& get_value_map() {
373 const value_map& get_value_map()
const {
378 void remove_registration(
const metric_id&
id);
380 return make_ready_future<>();
382 const config& get_config()
const {
385 void set_config(
const config& c) {
391 std::vector<std::deque<metric_function>>& functions();
393 void update_metrics_if_needed();
399 const std::set<sstring>& get_labels()
const noexcept {
405 const std::vector<relabel_config>& get_relabel_configs()
const noexcept {
406 return _relabel_configs;
408 const std::vector<metric_family_config>& get_metric_family_configs()
const noexcept {
409 return _metric_family_configs;
412 void set_metric_family_configs(
const std::vector<metric_family_config>& metrics_config);
417const value_map& get_value_map();
424void unregister_metric(
const metric_id &
id);
501const std::vector<relabel_config>& get_relabel_configs();
520void set_metric_family_configs(
const std::vector<metric_family_config>& metrics_config);
526const std::vector<metric_family_config>& get_metric_family_configs();
Definition: sharded.hh:945
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:253
Definition: metrics.hh:398
Definition: metrics_api.hh:240
Definition: metrics_api.hh:105
A helper class that used to return metrics value.
Definition: metrics.hh:294
Definition: metrics_api.hh:202
const sstring & name() const
returns the label name
Definition: metrics.hh:248
Definition: metrics_registration.hh:67
Definition: program-options.hh:293
Definition: shared_ptr.hh:507
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:355
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:350
Metrics configuration options.
Definition: metrics_api.hh:437
program_options::value< std::string > metrics_hostname
The hostname used by the metrics.
Definition: metrics_api.hh:441