Sfoglia il codice sorgente

Merge pull request #8 from zerotier/2152-disable-metrics

Allow metrics to be disabled
Joseph Henry 1 mese fa
parent
commit
300b05aaf0
3 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. 4 0
      RELEASE-NOTES.md
  2. 9 1
      service/OneService.cpp
  3. 1 1
      service/README.md

+ 4 - 0
RELEASE-NOTES.md

@@ -1,6 +1,10 @@
 ZeroTier Release Notes
 ======
 
+## WORK-IN-PROGRESS
+
+  * Metrics collection is now disabled by default. It can be enabled via the `enableMetrics` setting in `local.conf`.
+
 ## 2025-08-21 -- Version 1.16.0
 
   * License Changes

+ 9 - 1
service/OneService.cpp

@@ -988,7 +988,6 @@ class OneServiceImpl : public OneService {
 		_ports[1] = 0;
 		_ports[2] = 0;
 
-		prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
 		prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5));
 		prometheus::simpleapi::saver.set_out_file(_homePath + ZT_PATH_SEPARATOR + "metrics.prom");
 
@@ -2931,6 +2930,15 @@ class OneServiceImpl : public OneService {
 					_allowManagementFrom.push_back(nw);
 			}
 		}
+
+		bool enableMetrics = OSUtils::jsonBool(settings["enableMetrics"], false);
+		if (enableMetrics) {
+			prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
+		}
+		else {
+			std::shared_ptr<prometheus::Registry> registry;
+			prometheus::simpleapi::saver.set_registry(registry);
+		}
 	}
 
 #if ZT_VAULT_SUPPORT

+ 1 - 1
service/README.md

@@ -41,7 +41,7 @@ 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) */
+		"enableMetrics": true|false /* If true, enable the collection of metrics in metrics.prom. */
 	}
 }
 ```