summaryrefslogtreecommitdiffstats
path: root/dnsdist-prometheus.hh
diff options
context:
space:
mode:
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;
}