Explorar o código

Allow metrics to be disabled

Chris Spiegel hai 1 mes
pai
achega
48311896f8
Modificáronse 2 ficheiros con 11 adicións e 1 borrados
  1. 9 0
      service/OneService.cpp
  2. 2 1
      service/README.md

+ 9 - 0
service/OneService.cpp

@@ -2931,6 +2931,15 @@ class OneServiceImpl : public OneService {
 					_allowManagementFrom.push_back(nw);
 			}
 		}
+
+		bool disableMetrics = OSUtils::jsonBool(settings["disableMetrics"], false);
+		if (disableMetrics) {
+			std::shared_ptr<prometheus::Registry> registry;
+			prometheus::simpleapi::saver.set_registry(registry);
+		}
+		else {
+			prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
+		}
 	}
 
 #if ZT_VAULT_SUPPORT

+ 2 - 1
service/README.md

@@ -41,7 +41,8 @@ Settings available in `local.conf` (this is not valid JSON, and JSON does not al
 		"allowManagementFrom": [ "NETWORK/bits", ...] |null, /* If non-NULL, allow JSON/HTTP management from this IP network. Default is 127.0.0.1 only. */
 		"bind": [ "ip",... ], /* If present and non-null, bind to these IPs instead of to each interface (wildcard IP allowed) */
 		"allowTcpFallbackRelay": true|false, /* Allow or disallow establishment of TCP relay connections (true by default) */
-		"multipathMode": 0|1|2 /* multipath mode: none (0), random (1), proportional (2) */
+		"multipathMode": 0|1|2, /* multipath mode: none (0), random (1), proportional (2) */
+		"disableMetrics": true|false /* If true, disable the collection of metrics in metrics.prom. */
 	}
 }
 ```