]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Do not build prometheus support when DISABLE_PROMETHEUS is defined
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 8 Nov 2021 10:02:29 +0000 (11:02 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 22 Dec 2021 08:30:43 +0000 (09:30 +0100)
pdns/dnsdist-web.cc
pdns/dnsdistdist/dnsdist-prometheus.hh

index 81c81d88bc3d5e8f69a63bce25f7097966d6399c..e3cb116d6e9aad0cbfb1371ba28741626b5e6d7e 100644 (file)
@@ -60,7 +60,6 @@ struct WebserverConfig
 bool g_apiReadWrite{false};
 LockGuarded<WebserverConfig> g_webserverConfig;
 std::string g_apiConfigDirectory;
-static const MetricDefinitionStorage s_metricDefinitions;
 
 static ConcurrentConnectionManager s_connManager(100);
 
@@ -131,6 +130,9 @@ private:
   Socket d_socket;
 };
 
+#ifndef DISABLE_PROMETHEUS
+static const MetricDefinitionStorage s_metricDefinitions;
+
 const std::map<std::string, MetricDefinition> MetricDefinitionStorage::metrics{
   { "responses",              MetricDefinition(PrometheusMetricType::counter, "Number of responses received from backends") },
   { "servfail-responses",     MetricDefinition(PrometheusMetricType::counter, "Number of SERVFAIL answers received from backends") },
@@ -190,6 +192,7 @@ const std::map<std::string, MetricDefinition> MetricDefinitionStorage::metrics{
   { "tcp-listen-overflows",   MetricDefinition(PrometheusMetricType::counter, "From /proc/net/netstat ListenOverflows") },
   { "proxy-protocol-invalid", MetricDefinition(PrometheusMetricType::counter, "Number of queries dropped because of an invalid Proxy Protocol header") },
 };
+#endif /* DISABLE_PROMETHEUS */
 
 static bool apiWriteConfigFile(const string& filebasename, const string& content)
 {
@@ -407,6 +410,7 @@ static json11::Json::array someResponseRulesToJson(GlobalStateHolder<vector<T>>*
   return responseRules;
 }
 
+#ifndef DISABLE_PROMETHEUS
 template<typename T>
 static void addRulesToPrometheusOutput(std::ostringstream& output, GlobalStateHolder<vector<T> >& rules)
 {
@@ -810,6 +814,7 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp)
   resp.body = output.str();
   resp.headers["Content-Type"] = "text/plain";
 }
+#endif /* DISABLE_PROMETHEUS */
 
 using namespace json11;
 
@@ -1402,7 +1407,9 @@ static void handleBuiltInFiles(const YaHTTP::Request& req, YaHTTP::Response& res
 void registerBuiltInWebHandlers()
 {
   registerWebHandler("/jsonstat", handleJSONStats);
+#ifndef DISABLE_PROMETHEUS
   registerWebHandler("/metrics", handlePrometheus);
+#endif /* DISABLE_PROMETHEUS */
   registerWebHandler("/api/v1/servers/localhost", handleStats);
   registerWebHandler("/api/v1/servers/localhost/pool", handlePoolStats);
   registerWebHandler("/api/v1/servers/localhost/statistics", handleStatsOnly);
index a64b90495e21f2f749ef4750f3b577236e3d39f9..43bd6b3d50e0e7d235f0a9cba49d4be6e6809104 100644 (file)
@@ -21,6 +21,7 @@
  */
 #pragma once
 
+#ifndef DISABLE_PROMETHEUS
 // Metric types for Prometheus
 enum class PrometheusMetricType: int {
     counter = 1,
@@ -70,3 +71,4 @@ struct MetricDefinitionStorage {
 
   static const std::map<std::string, MetricDefinition> metrics;
 };
+#endif /* DISABLE_PROMETHEUS */