forked from mirrors/statsd_exporter
Minor fix-ups per PR discussion
* Removed extraneous newline * Reformatted/ordered imports * Used hash function to derive index of `Elements` instead of hardcoding hash result
This commit is contained in:
parent
b2082eda2b
commit
06444ed5c0
1 changed files with 6 additions and 4 deletions
|
@ -15,10 +15,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestNegativeCounter validates when we send a negative
|
// TestNegativeCounter validates when we send a negative
|
||||||
|
@ -83,14 +84,14 @@ type MockHistogram struct {
|
||||||
|
|
||||||
func (h *MockHistogram) Observe(n float64) {
|
func (h *MockHistogram) Observe(n float64) {
|
||||||
h.value = n
|
h.value = n
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHistogramUnits(t *testing.T) {
|
func TestHistogramUnits(t *testing.T) {
|
||||||
events := make(chan Events, 1)
|
events := make(chan Events, 1)
|
||||||
|
name := "foo"
|
||||||
c := Events{
|
c := Events{
|
||||||
&TimerEvent{
|
&TimerEvent{
|
||||||
metricName: "foo",
|
metricName: name,
|
||||||
value: 300,
|
value: 300,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,8 @@ func TestHistogramUnits(t *testing.T) {
|
||||||
close(events)
|
close(events)
|
||||||
}()
|
}()
|
||||||
mock := &MockHistogram{}
|
mock := &MockHistogram{}
|
||||||
ex.Histograms.Elements[7787632782521330630] = mock
|
key := hashNameAndLabels(name+"_timer", nil)
|
||||||
|
ex.Histograms.Elements[key] = mock
|
||||||
ex.Listen(events)
|
ex.Listen(events)
|
||||||
if mock.value == 300 {
|
if mock.value == 300 {
|
||||||
t.Fatalf("Histogram observations not scaled into Seconds")
|
t.Fatalf("Histogram observations not scaled into Seconds")
|
||||||
|
|
Loading…
Reference in a new issue