Skip to content

Commit

Permalink
Merge pull request #4 from desultory/dev
Browse files Browse the repository at this point in the history
ensure editing lables within metrics doesn't affect global labels
  • Loading branch information
desultory authored Nov 21, 2024
2 parents 0658b89 + 20af072 commit 76d0007
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ def test_global_labels_override(self):
for metric in random_metrics:
self.assertIn(f'{metric}{{global_label="global_value"}} 0', export)

def test_edited_metric_labels(self):
"""Test that editing labels on an added metric do not affect global labels"""
test_labels = {"label1": "value1", "label2": "value2"}
e = Exporter(no_config_file=True, labels=test_labels)
random_metrics = generate_random_metric_config(10)
e.config["metrics"] = random_metrics
e.metrics = []
e.export_config_metrics() # Generate metrics from the config
for metric in e.metrics:
self.assertEqual(metric.labels, test_labels)
metric.labels = {"asdf": str(uuid4())}
self.assertEqual(e.labels, test_labels)

def test_append_metrics(self):
"""Ensures metrics can be appended after init"""
Expand Down

0 comments on commit 76d0007

Please sign in to comment.