-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: normalize prometheus metric name
Ensure the Prometheus metric name are respecting Prometheus convention.
- Loading branch information
1 parent
83424af
commit ed110bb
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Unit tests.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Tests of Prometheus normalization metrics.""" | ||
from mqtt_exporter.main import _normalize_prometheus_metric_name | ||
|
||
|
||
def test_normalize_prometheus_metric_name(): | ||
"""Test _normalize_prometheus_metric_name.""" | ||
tests = { | ||
"1234invalid": ":1234invalid", | ||
"valid1234": "valid1234", | ||
"_this_is_valid": "_this_is_valid", | ||
"not_so_valid%_name": "not_so_valid_name", | ||
} | ||
|
||
for candidate, wanted in tests.items(): | ||
assert _normalize_prometheus_metric_name(candidate) == wanted |