diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
commit | 2f230033794fafdf10822568e763d4db68cf6c6b (patch) | |
tree | 39ca5c2325b7b43c9a28ca6d4ad4026a61e7eb97 /dnsdist-prometheus.hh | |
parent | Adding debian version 1.8.3-3. (diff) | |
download | dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.tar.xz dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.zip |
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dnsdist-prometheus.hh')
-rw-r--r-- | dnsdist-prometheus.hh | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/dnsdist-prometheus.hh b/dnsdist-prometheus.hh index 15567bf..011053d 100644 --- a/dnsdist-prometheus.hh +++ b/dnsdist-prometheus.hh @@ -21,6 +21,17 @@ */ #pragma once +namespace dnsdist::prometheus +{ +struct PrometheusMetricDefinition +{ + const std::string& name; + const std::string& type; + const std::string& description; + const std::string& customName; +}; +} + #ifndef DISABLE_PROMETHEUS // Metric types for Prometheus enum class PrometheusMetricType: uint8_t { @@ -56,16 +67,16 @@ struct MetricDefinitionStorage { return true; }; - static bool addMetricDefinition(const std::string& name, const std::string& type, const std::string& description, const std::string& customName) { + static bool addMetricDefinition(const dnsdist::prometheus::PrometheusMetricDefinition& def) { static const std::map<std::string, PrometheusMetricType> namesToTypes = { {"counter", PrometheusMetricType::counter}, {"gauge", PrometheusMetricType::gauge}, }; - auto realtype = namesToTypes.find(type); + auto realtype = namesToTypes.find(def.type); if (realtype == namesToTypes.end()) { return false; } - metrics.emplace(name, MetricDefinition{realtype->second, description, customName}); + metrics.emplace(def.name, MetricDefinition{realtype->second, def.description, def.customName}); return true; } |