Skip to content

Commit

Permalink
Log cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
UTXOnly committed Jan 14, 2025
1 parent 1ceb079 commit 27a1a97
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,27 @@ def __call__(self, metrics):
metric_config = self.metric_config.copy()
target_info_metric = self.info_metric.copy()
cached_metrics = []

for metric in metrics:
if metric_config and metric.name in metric_config:
self.collect(metric, metric_config.pop(metric.name))

if target_info_metric and metric.name in target_info_metric:
self.collect(metric, target_info_metric.pop(metric.name))

cached_metrics.append(metric)

if not (metric_config or target_info_metric):
break

yield from cached_metrics
yield from metrics
finally:
self.label_sets.clear()
self.unconditional_labels.clear()


def collect(self, metric, config):
allowed_values = config.get('values')
self.logger.debug("Collect config is: %s", config)

if 'match' in config:
matching_labels = config['match']
Expand All @@ -138,7 +136,6 @@ def collect(self, metric, config):
shared_labels[label] = value

self.label_sets.append((label_set, shared_labels))
self.logger.debug("Labelset is %s, shared labels is %s", label_set, shared_labels)
else:
for sample in self.allowed_samples(metric, allowed_values):
label_set = set()
Expand All @@ -151,7 +148,6 @@ def collect(self, metric, config):
shared_labels[label] = value

self.label_sets.append((label_set, shared_labels))
self.logger.debug("Labelset - else is %s, shared labels is %s", label_set, shared_labels)
else:
if 'labels' in config:
labels = config['labels']
Expand All @@ -169,9 +165,6 @@ def populate(self, labels):
labels.update(self.unconditional_labels)

for matching_label_set, shared_labels in self.label_sets:
self.logger.debug(
"self.label sets, matching label is %s, shared label is %s", matching_label_set, shared_labels
)
# Check for subset without incurring the cost of a `.issubset` lookup and call
if matching_label_set <= label_set:
labels.update(shared_labels)
Expand Down

0 comments on commit 27a1a97

Please sign in to comment.