mirror of
				https://github.com/KevinMidboe/mktxp-no-cli.git
				synced 2025-10-29 17:50:23 +00:00 
			
		
		
		
	metric_labels memoty leak fix, per #34
This commit is contained in:
		| @@ -21,7 +21,9 @@ class BaseCollector: | |||||||
|         For use by custom collector |         For use by custom collector | ||||||
|     ''' |     ''' | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def info_collector(name, decription, router_records, metric_labels=[]): |     def info_collector(name, decription, router_records, metric_labels=None): | ||||||
|  |         if metric_labels is None: | ||||||
|  |             metric_labels = [] | ||||||
|         BaseCollector._add_id_labels(metric_labels) |         BaseCollector._add_id_labels(metric_labels) | ||||||
|         collector = InfoMetricFamily(f'mktxp_{name}', decription) |         collector = InfoMetricFamily(f'mktxp_{name}', decription) | ||||||
|  |  | ||||||
| @@ -31,7 +33,9 @@ class BaseCollector: | |||||||
|         return collector |         return collector | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def counter_collector(name, decription, router_records, metric_key, metric_labels=[]): |     def counter_collector(name, decription, router_records, metric_key, metric_labels=None): | ||||||
|  |         if metric_labels is None: | ||||||
|  |             metric_labels = [] | ||||||
|         BaseCollector._add_id_labels(metric_labels) |         BaseCollector._add_id_labels(metric_labels) | ||||||
|         collector = CounterMetricFamily(f'mktxp_{name}', decription, labels=metric_labels) |         collector = CounterMetricFamily(f'mktxp_{name}', decription, labels=metric_labels) | ||||||
|  |  | ||||||
| @@ -41,7 +45,9 @@ class BaseCollector: | |||||||
|         return collector |         return collector | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def gauge_collector(name, decription, router_records, metric_key, metric_labels=[], add_id_labels = True): |     def gauge_collector(name, decription, router_records, metric_key, metric_labels=None, add_id_labels = True): | ||||||
|  |         if metric_labels is None: | ||||||
|  |             metric_labels = []         | ||||||
|         if add_id_labels: |         if add_id_labels: | ||||||
|             BaseCollector._add_id_labels(metric_labels) |             BaseCollector._add_id_labels(metric_labels) | ||||||
|         collector = GaugeMetricFamily(f'mktxp_{name}', decription, labels=metric_labels) |         collector = GaugeMetricFamily(f'mktxp_{name}', decription, labels=metric_labels) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user