@@ -450,6 +450,7 @@ func TestPacketHandlerGauge(t *testing.T) {
450
450
451
451
func TestPacketHandlerTimer (t * testing.T ) {
452
452
timers = make (map [string ]Float64Slice )
453
+ counters = make (map [string ]float64 )
453
454
454
455
p := & Packet {
455
456
Bucket : "glork" ,
@@ -460,11 +461,13 @@ func TestPacketHandlerTimer(t *testing.T) {
460
461
packetHandler (p )
461
462
assert .Equal (t , len (timers ["glork" ]), 1 )
462
463
assert .Equal (t , timers ["glork" ][0 ], float64 (320 ))
464
+ assert .Equal (t , counters ["glork.count" ], 1.0 )
463
465
464
466
p .ValFlt = float64 (100 )
465
467
packetHandler (p )
466
468
assert .Equal (t , len (timers ["glork" ]), 2 )
467
469
assert .Equal (t , timers ["glork" ][1 ], float64 (100 ))
470
+ assert .Equal (t , counters ["glork.count" ], 2.0 )
468
471
}
469
472
470
473
func TestPacketHandlerSet (t * testing.T ) {
@@ -558,7 +561,7 @@ func TestProcessTimers(t *testing.T) {
558
561
assert .Equal (t , string (lines [0 ]), "response_time.mean 20 1418052649" )
559
562
assert .Equal (t , string (lines [1 ]), "response_time.upper 30 1418052649" )
560
563
assert .Equal (t , string (lines [2 ]), "response_time.lower 0 1418052649" )
561
- assert . Equal ( t , string ( lines [ 3 ]), " response_time.count 3 1418052649" )
564
+ // response_time.count handled by processCounters, not processTimers
562
565
563
566
num = processTimers (& buffer , now , Percentiles {})
564
567
assert .Equal (t , num , int64 (0 ))
@@ -769,7 +772,11 @@ func TestMultipleUDPSends(t *testing.T) {
769
772
}
770
773
771
774
func BenchmarkManyDifferentSensors (t * testing.B ) {
775
+ counters = make (map [string ]float64 )
776
+ gauges = make (map [string ]float64 )
777
+ timers = make (map [string ]Float64Slice )
772
778
r := rand .New (rand .NewSource (438 ))
779
+
773
780
for i := 0 ; i < 1000 ; i ++ {
774
781
bucket := "response_time" + strconv .Itoa (i )
775
782
for i := 0 ; i < 10000 ; i ++ {
@@ -925,6 +932,7 @@ func BenchmarkPacketHandlerTimer(b *testing.B) {
925
932
d1 := parseLine ([]byte ("glork.some.keyspace:3.7211|ms" ))
926
933
d2 := parseLine ([]byte ("glork.some.keyspace:11223|ms" ))
927
934
timers = make (map [string ]Float64Slice )
935
+ counters = make (map [string ]float64 )
928
936
929
937
for i := 0 ; i < b .N ; i ++ {
930
938
packetHandler (d1 )
0 commit comments