Fix mapping example in the README

Strings with leading asterisks need to be escaped in YAML.

Add the same examples into the test suite to make sure they do what we
claim they do.

Fixes #102.
This commit is contained in:
Matthias Rampke 2017-11-10 20:18:57 +00:00
parent 45d22f2add
commit 6c04ec1d89
2 changed files with 36 additions and 1 deletions

View file

@ -107,7 +107,7 @@ mappings:
action: "$2"
outcome: "$3"
job: "test_dispatcher"
- match: *.signup.*.*
- match: "*.signup.*.*"
labels:
name: "signup_events_total"
provider: "$2"

View file

@ -265,6 +265,41 @@ mappings:
`,
configBad: true,
},
// Example from the README.
{
config: `
mappings:
- match: test.dispatcher.*.*.*
labels:
name: "dispatcher_events_total"
processor: "$1"
action: "$2"
outcome: "$3"
job: "test_dispatcher"
- match: "*.signup.*.*"
labels:
name: "signup_events_total"
provider: "$2"
outcome: "$3"
job: "${1}_server"
`,
mappings: map[string]map[string]string{
"test.dispatcher.FooProcessor.send.success": map[string]string{
"name": "dispatcher_events_total",
"processor": "FooProcessor",
"action": "send",
"outcome": "success",
"job": "test_dispatcher",
},
"foo_product.signup.facebook.failure": map[string]string{
"name": "signup_events_total",
"provider": "facebook",
"outcome": "failure",
"job": "foo_product_server",
},
"test.web-server.foo.bar": map[string]string{},
},
},
}
mapper := metricMapper{}