@@ -14,54 +14,66 @@ import (
1414func TestMetricsLexer (t * testing.T ) {
1515 t .Parallel ()
1616 tests := map [string ]gostatsd.Metric {
17- "foo.bar.baz:2|c" : {Name : "foo.bar.baz" , Value : 2 , Type : gostatsd .COUNTER , Rate : 1.0 },
18- "abc.def.g:3|g" : {Name : "abc.def.g" , Value : 3 , Type : gostatsd .GAUGE , Rate : 1.0 },
19- "def.g:10|ms" : {Name : "def.g" , Value : 10 , Type : gostatsd .TIMER , Rate : 1.0 },
20- "def.h:10|h" : {Name : "def.h" , Value : 10 , Type : gostatsd .TIMER , Rate : 1.0 },
21- "def.i:10|h|#foo" : {Name : "def.i" , Value : 10 , Type : gostatsd .TIMER , Rate : 1.0 , Tags : gostatsd.Tags {"foo" }},
22- "smp.rte:5|c|@0.1" : {Name : "smp.rte" , Value : 5 , Type : gostatsd .COUNTER , Rate : 0.1 },
23- "smp.rte:5|c|@0.1|#foo:bar,baz" : {Name : "smp.rte" , Value : 5 , Type : gostatsd .COUNTER , Rate : 0.1 , Tags : gostatsd.Tags {"foo:bar" , "baz" }},
24- "smp.rte:5|c|#foo:bar,baz" : {Name : "smp.rte" , Value : 5 , Type : gostatsd .COUNTER , Rate : 1.0 , Tags : gostatsd.Tags {"foo:bar" , "baz" }},
17+ "foo.bar.baz:2|c" : {Name : "foo.bar.baz" , Values : [] float64 { 2 } , Type : gostatsd .COUNTER , Rate : 1.0 },
18+ "abc.def.g:3|g" : {Name : "abc.def.g" , Values : [] float64 { 3 } , Type : gostatsd .GAUGE , Rate : 1.0 },
19+ "def.g:10|ms" : {Name : "def.g" , Values : [] float64 { 10 } , Type : gostatsd .TIMER , Rate : 1.0 },
20+ "def.h:10|h" : {Name : "def.h" , Values : [] float64 { 10 } , Type : gostatsd .TIMER , Rate : 1.0 },
21+ "def.i:10|h|#foo" : {Name : "def.i" , Values : [] float64 { 10 } , Type : gostatsd .TIMER , Rate : 1.0 , Tags : gostatsd.Tags {"foo" }},
22+ "smp.rte:5|c|@0.1" : {Name : "smp.rte" , Values : [] float64 { 5 } , Type : gostatsd .COUNTER , Rate : 0.1 },
23+ "smp.rte:5|c|@0.1|#foo:bar,baz" : {Name : "smp.rte" , Values : [] float64 { 5 } , Type : gostatsd .COUNTER , Rate : 0.1 , Tags : gostatsd.Tags {"foo:bar" , "baz" }},
24+ "smp.rte:5|c|#foo:bar,baz" : {Name : "smp.rte" , Values : [] float64 { 5 } , Type : gostatsd .COUNTER , Rate : 1.0 , Tags : gostatsd.Tags {"foo:bar" , "baz" }},
2525 "uniq.usr:joe|s" : {Name : "uniq.usr" , StringValue : "joe" , Type : gostatsd .SET , Rate : 1.0 },
26- "fooBarBaz:2|c" : {Name : "fooBarBaz" , Value : 2 , Type : gostatsd .COUNTER , Rate : 1.0 },
27- "smp.rte:5|c|#Foo:Bar,baz" : {Name : "smp.rte" , Value : 5 , Type : gostatsd .COUNTER , Rate : 1.0 , Tags : gostatsd.Tags {"Foo:Bar" , "baz" }},
28- "smp.gge:1|g|#Foo:Bar" : {Name : "smp.gge" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"Foo:Bar" }},
29- "smp.gge:1|g|#fo_o:ba-r" : {Name : "smp.gge" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"fo_o:ba-r" }},
30- "smp gge:1|g" : {Name : "smp_gge" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
31- "smp/gge:1|g" : {Name : "smp-gge" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
32- "smp,gge$:1|g" : {Name : "smpgge" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
26+ "fooBarBaz:2|c" : {Name : "fooBarBaz" , Values : [] float64 { 2 } , Type : gostatsd .COUNTER , Rate : 1.0 },
27+ "smp.rte:5|c|#Foo:Bar,baz" : {Name : "smp.rte" , Values : [] float64 { 5 } , Type : gostatsd .COUNTER , Rate : 1.0 , Tags : gostatsd.Tags {"Foo:Bar" , "baz" }},
28+ "smp.gge:1|g|#Foo:Bar" : {Name : "smp.gge" , Values : [] float64 { 1 } , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"Foo:Bar" }},
29+ "smp.gge:1|g|#fo_o:ba-r" : {Name : "smp.gge" , Values : [] float64 { 1 } , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"fo_o:ba-r" }},
30+ "smp gge:1|g" : {Name : "smp_gge" , Values : [] float64 { 1 } , Type : gostatsd .GAUGE , Rate : 1.0 },
31+ "smp/gge:1|g" : {Name : "smp-gge" , Values : [] float64 { 1 } , Type : gostatsd .GAUGE , Rate : 1.0 },
32+ "smp,gge$:1|g" : {Name : "smpgge" , Values : [] float64 { 1 } , Type : gostatsd .GAUGE , Rate : 1.0 },
3333 "un1qu3:john|s" : {Name : "un1qu3" , StringValue : "john" , Type : gostatsd .SET , Rate : 1.0 },
3434 "un1qu3:john|s|#some:42" : {Name : "un1qu3" , StringValue : "john" , Type : gostatsd .SET , Rate : 1.0 , Tags : gostatsd.Tags {"some:42" }},
3535 "da-sh:1|s" : {Name : "da-sh" , StringValue : "1" , Type : gostatsd .SET , Rate : 1.0 },
3636 "under_score:1|s" : {Name : "under_score" , StringValue : "1" , Type : gostatsd .SET , Rate : 1.0 },
37- "a:1|g|#f,," : {Name : "a" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
38- "a:1|g|#,,f" : {Name : "a" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
39- "a:1|g|#f,,z" : {Name : "a" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" , "z" }},
40- "a:1|g|#" : {Name : "a" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
41- "a:1|g|#," : {Name : "a" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
42- "a:1|g|#,," : {Name : "a" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
43- "foo.bar.baz:2|c|c:xyz" : {Name : "foo.bar.baz" , Value : 2 , Type : gostatsd .COUNTER , Rate : 1.0 },
44- "smp.rte:5|c|@0.1|c:xyz" : {Name : "smp.rte" , Value : 5 , Type : gostatsd .COUNTER , Rate : 0.1 },
45- "smp.rte:5|c|@0.1|#foo:bar,baz|c:xyz" : {Name : "smp.rte" , Value : 5 , Type : gostatsd .COUNTER , Rate : 0.1 , Tags : gostatsd.Tags {"foo:bar" , "baz" }},
46- "def.i:10|h|#foo|c:xyz" : {Name : "def.i" , Value : 10 , Type : gostatsd .TIMER , Rate : 1.0 , Tags : gostatsd.Tags {"foo" }},
47- "c.after.tags:1|g|#f,,|c:xyz" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
48- "c.after.tags:1|g|#,,f|c:xyz" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
49- "c.after.tags:1|g|#f,,z|c:xyz" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" , "z" }},
50- "c.after.tags:1|g|#|c:xyz" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
51- "c.after.tags:1|g|#,|c:xyz" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
52- "c.after.tags:1|g|#,,|c:xyz" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
53- "c.after.tags:1|g|#,,|c::,#@" : {Name : "c.after.tags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
54- "field.order.rev.all:1|g|c:xyz|#foo:bar|@0.1" : {Name : "field.order.rev.all" , Value : 1 , Type : gostatsd .GAUGE , Rate : 0.1 , Tags : gostatsd.Tags {"foo:bar" }},
55- "field.order.rev.notags:1|g|c:xyz|@0.1" : {Name : "field.order.rev.notags" , Value : 1 , Type : gostatsd .GAUGE , Rate : 0.1 },
56- "new.last.prefix:1|g|#,,|c:xyz|x:" : {Name : "new.last.prefix" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
57- "new.last.empty:1|g|#,|c:xyz|" : {Name : "new.last.empty" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
58- "new.last.colon:1|g|#|c:xyz|:" : {Name : "new.last.colon" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
59- "new.first.prefix:1|g|x:#,,|c:xyz|" : {Name : "new.first.prefix" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
60- "new.first.empty:1|g||#,|c:xyz" : {Name : "new.first.empty" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
61- "new.first.colon:1|g|:|#|c:xyz" : {Name : "new.first.colon" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
62- "new.mid.prefix:1|g|#,,|x:|c:xyz" : {Name : "new.mid.prefix" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
63- "new.mid.empty:1|g|#,||c:xyz" : {Name : "new.mid.empty" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
64- "new.mid.colon:1|g|#|:|c:xyz" : {Name : "new.mid.colon" , Value : 1 , Type : gostatsd .GAUGE , Rate : 1.0 },
37+ "a:1|g|#f,," : {Name : "a" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
38+ "a:1|g|#,,f" : {Name : "a" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
39+ "a:1|g|#f,,z" : {Name : "a" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" , "z" }},
40+ "a:1|g|#" : {Name : "a" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
41+ "a:1|g|#," : {Name : "a" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
42+ "a:1|g|#,," : {Name : "a" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
43+ "foo.bar.baz:2|c|c:xyz" : {Name : "foo.bar.baz" , Values : []float64 {2 }, Type : gostatsd .COUNTER , Rate : 1.0 },
44+ "smp.rte:5|c|@0.1|c:xyz" : {Name : "smp.rte" , Values : []float64 {5 }, Type : gostatsd .COUNTER , Rate : 0.1 },
45+ "smp.rte:5|c|@0.1|#foo:bar,baz|c:xyz" : {Name : "smp.rte" , Values : []float64 {5 }, Type : gostatsd .COUNTER , Rate : 0.1 , Tags : gostatsd.Tags {"foo:bar" , "baz" }},
46+ "def.i:10|h|#foo|c:xyz" : {Name : "def.i" , Values : []float64 {10 }, Type : gostatsd .TIMER , Rate : 1.0 , Tags : gostatsd.Tags {"foo" }},
47+ "c.after.tags:1|g|#f,,|c:xyz" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
48+ "c.after.tags:1|g|#,,f|c:xyz" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" }},
49+ "c.after.tags:1|g|#f,,z|c:xyz" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 , Tags : gostatsd.Tags {"f" , "z" }},
50+ "c.after.tags:1|g|#|c:xyz" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
51+ "c.after.tags:1|g|#,|c:xyz" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
52+ "c.after.tags:1|g|#,,|c:xyz" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
53+ "c.after.tags:1|g|#,,|c::,#@" : {Name : "c.after.tags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
54+ "field.order.rev.all:1|g|c:xyz|#foo:bar|@0.1" : {Name : "field.order.rev.all" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 0.1 , Tags : gostatsd.Tags {"foo:bar" }},
55+ "field.order.rev.notags:1|g|c:xyz|@0.1" : {Name : "field.order.rev.notags" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 0.1 },
56+ "new.last.prefix:1|g|#,,|c:xyz|x:" : {Name : "new.last.prefix" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
57+ "new.last.empty:1|g|#,|c:xyz|" : {Name : "new.last.empty" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
58+ "new.last.colon:1|g|#|c:xyz|:" : {Name : "new.last.colon" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
59+ "new.first.prefix:1|g|x:#,,|c:xyz|" : {Name : "new.first.prefix" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
60+ "new.first.empty:1|g||#,|c:xyz" : {Name : "new.first.empty" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
61+ "new.first.colon:1|g|:|#|c:xyz" : {Name : "new.first.colon" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
62+ "new.mid.prefix:1|g|#,,|x:|c:xyz" : {Name : "new.mid.prefix" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
63+ "new.mid.empty:1|g|#,||c:xyz" : {Name : "new.mid.empty" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
64+ "new.mid.colon:1|g|#|:|c:xyz" : {Name : "new.mid.colon" , Values : []float64 {1 }, Type : gostatsd .GAUGE , Rate : 1.0 },
65+ // Value packing tests
66+ "a.packing:1:2|ms|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 }, Type : gostatsd .TIMER , Rate : 1.0 },
67+ "a.packing:1:2:3|ms|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 , 3 }, Type : gostatsd .TIMER , Rate : 1.0 },
68+ "a.packing:1:2:|ms|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 }, Type : gostatsd .TIMER , Rate : 1.0 },
69+ "a.packing:|ms|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {}, Type : gostatsd .TIMER , Rate : 1.0 },
70+ "a.packing:1:2|c|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 }, Type : gostatsd .COUNTER , Rate : 1.0 },
71+ "a.packing:1:2:3|c|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 , 3 }, Type : gostatsd .COUNTER , Rate : 1.0 },
72+ "a.packing:1:2:|c|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 }, Type : gostatsd .COUNTER , Rate : 1.0 },
73+ "a.packing:1:2|g|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 }, Type : gostatsd .GAUGE , Rate : 1.0 },
74+ "a.packing:1:2:3|g|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 , 3 }, Type : gostatsd .GAUGE , Rate : 1.0 },
75+ "a.packing:1:2:|g|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {1 , 2 }, Type : gostatsd .GAUGE , Rate : 1.0 },
76+ "a.packing:::|g|#|:|c:xyz" : {Name : "a.packing" , Values : []float64 {}, Type : gostatsd .GAUGE , Rate : 1.0 },
6577 }
6678
6779 compareMetric (t , tests , "" )
@@ -85,9 +97,9 @@ func TestInvalidMetricsLexer(t *testing.T) {
8597 }
8698
8799 tests := map [string ]gostatsd.Metric {
88- "foo.bar.baz:2|c" : {Name : "stats.foo.bar.baz" , Value : 2 , Type : gostatsd .COUNTER , Rate : 1.0 },
89- "abc.def.g:3|g" : {Name : "stats.abc.def.g" , Value : 3 , Type : gostatsd .GAUGE , Rate : 1.0 },
90- "def.g:10|ms" : {Name : "stats.def.g" , Value : 10 , Type : gostatsd .TIMER , Rate : 1.0 },
100+ "foo.bar.baz:2|c" : {Name : "stats.foo.bar.baz" , Values : [] float64 { 2 } , Type : gostatsd .COUNTER , Rate : 1.0 },
101+ "abc.def.g:3|g" : {Name : "stats.abc.def.g" , Values : [] float64 { 3 } , Type : gostatsd .GAUGE , Rate : 1.0 },
102+ "def.g:10|ms" : {Name : "stats.def.g" , Values : [] float64 { 10 } , Type : gostatsd .TIMER , Rate : 1.0 },
91103 "uniq.usr:joe|s" : {Name : "stats.uniq.usr" , StringValue : "joe" , Type : gostatsd .SET , Rate : 1.0 },
92104 }
93105
0 commit comments