From cfcf3c9ba51bc28ec32b01eb44001a4937bb5758 Mon Sep 17 00:00:00 2001 From: Brian Akins Date: Tue, 9 Apr 2019 14:10:26 -0400 Subject: [PATCH] Add comments explaining escapeMetricName Signed-off-by: Brian Akins --- exporter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exporter.go b/exporter.go index a2ad52f..81fd385 100644 --- a/exporter.go +++ b/exporter.go @@ -288,6 +288,10 @@ func escapeMetricName(metricName string) string { out := make([]byte, len(metricName)) j := 0 for _, c := range metricName { + // check if the rune is valid for a metric name + // and replace it if it is not. + // As only certain ASCII characters are valid in metric names, + // we can use a byte. if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') {