summaryrefslogtreecommitdiffstats
path: root/dnsdist-prometheus.hh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:14:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:14:49 +0000
commit2f230033794fafdf10822568e763d4db68cf6c6b (patch)
tree39ca5c2325b7b43c9a28ca6d4ad4026a61e7eb97 /dnsdist-prometheus.hh
parentAdding debian version 1.8.3-3. (diff)
downloaddnsdist-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.hh17
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;
}