Fix issue 657 - support for super hero protocol(estatsd)

This commit is contained in:
Lukasz Jagiello 2016-02-07 18:25:42 +00:00
parent 9a59512f75
commit adfab1cb2c
2 changed files with 10 additions and 2 deletions

View File

@ -324,7 +324,7 @@ func (s *Statsd) parseStatsdLine(line string) error {
// Validate metric type
switch pipesplit[1] {
case "g", "c", "s", "ms", "h":
case "g", "c", "s", "ms", "mr", "m", "h":
m.mtype = pipesplit[1]
default:
log.Printf("Error: Statsd Metric type %s unsupported", pipesplit[1])
@ -348,7 +348,7 @@ func (s *Statsd) parseStatsdLine(line string) error {
return errors.New("Error Parsing statsd line")
}
m.floatvalue = v
case "c", "s":
case "c", "s", "m", "mr":
var v int64
v, err := strconv.ParseInt(pipesplit[0], 10, 64)
if err != nil {
@ -382,6 +382,10 @@ func (s *Statsd) parseStatsdLine(line string) error {
m.tags["metric_type"] = "set"
case "ms":
m.tags["metric_type"] = "timing"
case "mr":
m.tags["metric_type"] = "micrometer"
case "m":
m.tags["metric_type"] = "meter"
case "h":
m.tags["metric_type"] = "histogram"
}

View File

@ -18,6 +18,8 @@ func TestParse_InvalidLines(t *testing.T) {
"invalid.plus.minus.non.gauge:+10|c",
"invalid.plus.minus.non.gauge:+10|s",
"invalid.plus.minus.non.gauge:+10|ms",
"invalid.plus.minus.non.gauge:+10|mr",
"invalid.plus.minus.non.gauge:+10|m",
"invalid.plus.minus.non.gauge:+10|h",
"invalid.plus.minus.non.gauge:-10|c",
"invalid.value:foobar|c",
@ -627,6 +629,8 @@ func TestParse_ValidLines(t *testing.T) {
valid_lines := []string{
"valid:45|c",
"valid:45|s",
"valid:45|m",
"valid:45|mr",
"valid:45|g",
"valid.timer:45|ms",
"valid.timer:45|h",