metric_labels memoty leak fix, per #34

This commit is contained in:
Arseniy Kuznetsov
2022-09-17 15:59:18 +01:00
parent ad3f4b2f5d
commit dc3f93896d

View File

@@ -21,7 +21,9 @@ class BaseCollector:
For use by custom collector
'''
@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)
collector = InfoMetricFamily(f'mktxp_{name}', decription)
@@ -31,7 +33,9 @@ class BaseCollector:
return collector
@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)
collector = CounterMetricFamily(f'mktxp_{name}', decription, labels=metric_labels)
@@ -41,7 +45,9 @@ class BaseCollector:
return collector
@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:
BaseCollector._add_id_labels(metric_labels)
collector = GaugeMetricFamily(f'mktxp_{name}', decription, labels=metric_labels)