allow metrics with dashes when mapping

This commit is contained in:
Mac Browning 2015-10-09 18:03:21 -04:00
parent 4270a5ed7e
commit 411b071f1f
2 changed files with 27 additions and 3 deletions

View file

@ -25,7 +25,9 @@ import (
var (
identifierRE = `[a-zA-Z_][a-zA-Z0-9_]+`
metricLineRE = regexp.MustCompile(`^(\*\.|` + identifierRE + `\.)+(\*|` + identifierRE + `)$`)
statsdMetricRE = `[a-zA-Z_](-?[a-zA-Z0-9_])+`
metricLineRE = regexp.MustCompile(`^(\*\.|` + statsdMetricRE + `\.)+(\*|` + statsdMetricRE + `)$`)
labelLineRE = regexp.MustCompile(`^(` + identifierRE + `)\s*=\s*"(.*)"$`)
metricNameRE = regexp.MustCompile(`^` + identifierRE + `$`)
)

View file

@ -35,6 +35,13 @@ func TestMetricMapper(t *testing.T) {
result="$3"
job="test_dispatcher"
test.my-dispatch-host01.name.dispatcher.*.*.*
name="host_dispatch_events"
processor="$1"
action="$2"
result="$3"
job="test_dispatcher"
*.*
name="catchall"
first="$1"
@ -50,6 +57,13 @@ func TestMetricMapper(t *testing.T) {
"result": "succeeded",
"job": "test_dispatcher",
},
"test.my-dispatch-host01.name.dispatcher.FooProcessor.send.succeeded": map[string]string{
"name": "host_dispatch_events",
"processor": "FooProcessor",
"action": "send",
"result": "succeeded",
"job": "test_dispatcher",
},
"foo.bar": map[string]string{
"name": "catchall",
"first": "foo",
@ -91,7 +105,7 @@ func TestMetricMapper(t *testing.T) {
// Config with bad metric line.
{
config: `
bad-metric-line.*.*
bad--metric-line.*.*
name="foo"
`,
configBad: true,
@ -104,6 +118,14 @@ func TestMetricMapper(t *testing.T) {
`,
configBad: true,
},
// Config with bad label line.
{
config: `
test.*.*
name="foo-name"
`,
configBad: true,
},
// Config with bad metric name.
{
config: `