Skip to content

Commit

Permalink
Don't sanitize away colons in metric names (#498)
Browse files Browse the repository at this point in the history
The docs specify that colons (`:`) are allowed in metric names, but
`Collector.sanitizeMetricName` removes them.

Signed-off-by: ugniusb <ugniusb@wix.com>
  • Loading branch information
ugniusb authored and brian-brazil committed Sep 4, 2019
1 parent 8b0c045 commit 10fa80b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ protected static void checkMetricName(String name) {
}
}

private static final Pattern SANITIZE_PREFIX_PATTERN = Pattern.compile("^[^a-zA-Z_]");
private static final Pattern SANITIZE_BODY_PATTERN = Pattern.compile("[^a-zA-Z0-9_]");
private static final Pattern SANITIZE_PREFIX_PATTERN = Pattern.compile("^[^a-zA-Z_:]");
private static final Pattern SANITIZE_BODY_PATTERN = Pattern.compile("[^a-zA-Z0-9_:]");

/**
* Sanitize metric name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class CollectorTest {
public void sanitizeMetricName() throws Exception {
assertEquals("_hoge", Collector.sanitizeMetricName("0hoge"));
assertEquals("foo_bar0", Collector.sanitizeMetricName("foo.bar0"));
assertEquals(":baz::", Collector.sanitizeMetricName(":baz::"));
}
}

0 comments on commit 10fa80b

Please sign in to comment.