forked from mirrors/statsd_exporter
Add comments explaining escapeMetricName
Signed-off-by: Brian Akins <brian@akins.org>
This commit is contained in:
parent
7f70979120
commit
cfcf3c9ba5
1 changed files with 4 additions and 0 deletions
|
@ -288,6 +288,10 @@ func escapeMetricName(metricName string) string {
|
||||||
out := make([]byte, len(metricName))
|
out := make([]byte, len(metricName))
|
||||||
j := 0
|
j := 0
|
||||||
for _, c := range metricName {
|
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') ||
|
if (c >= 'a' && c <= 'z') ||
|
||||||
(c >= 'A' && c <= 'Z') ||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
(c >= '0' && c <= '9') {
|
(c >= '0' && c <= '9') {
|
||||||
|
|
Loading…
Reference in a new issue