forked from mirrors/statsd_exporter
add signalfx tag parsing to main benchmark tests
Signed-off-by: glightfoot <glightfoot@rsglab.com>
This commit is contained in:
parent
32f1677f81
commit
b4ce2913fa
3 changed files with 33 additions and 3 deletions
|
@ -179,6 +179,26 @@ func TestHandlePacket(t *testing.T) {
|
||||||
CLabels: map[string]string{"tag1": "bar", "tag2": "baz"},
|
CLabels: map[string]string{"tag1": "bar", "tag2": "baz"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
name: "SignalFx tag extension, tags at end of name",
|
||||||
|
in: "foo.test[tag1=bar,tag2=baz]:100|c",
|
||||||
|
out: event.Events{
|
||||||
|
&event.CounterEvent{
|
||||||
|
CMetricName: "foo.test",
|
||||||
|
CValue: 100,
|
||||||
|
CLabels: map[string]string{"tag1": "bar", "tag2": "baz"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
name: "SignalFx tag extension, tags at beginning of name",
|
||||||
|
in: "[tag1=bar,tag2=baz]foo.test:100|c",
|
||||||
|
out: event.Events{
|
||||||
|
&event.CounterEvent{
|
||||||
|
CMetricName: "foo.test",
|
||||||
|
CValue: 100,
|
||||||
|
CLabels: map[string]string{"tag1": "bar", "tag2": "baz"},
|
||||||
|
},
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "influxdb tag extension with tag keys unsupported by prometheus",
|
name: "influxdb tag extension with tag keys unsupported by prometheus",
|
||||||
in: "foo,09digits=0,tag.with.dots=1:100|c",
|
in: "foo,09digits=0,tag.with.dots=1:100|c",
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
|
|
||||||
"github.com/prometheus/statsd_exporter/pkg/event"
|
"github.com/prometheus/statsd_exporter/pkg/event"
|
||||||
"github.com/prometheus/statsd_exporter/pkg/exporter"
|
"github.com/prometheus/statsd_exporter/pkg/exporter"
|
||||||
"github.com/prometheus/statsd_exporter/pkg/listener"
|
"github.com/prometheus/statsd_exporter/pkg/listener"
|
||||||
|
@ -34,10 +35,12 @@ func benchmarkUDPListener(times int, b *testing.B) {
|
||||||
"foo6:100|c|#09digits:0,tag.with.dots:1",
|
"foo6:100|c|#09digits:0,tag.with.dots:1",
|
||||||
"foo10:100|c|@0.1|#tag1:bar,#tag2:baz",
|
"foo10:100|c|@0.1|#tag1:bar,#tag2:baz",
|
||||||
"foo11:100|c|@0.1|#tag1:foo:bar",
|
"foo11:100|c|@0.1|#tag1:foo:bar",
|
||||||
|
"foo.[foo=bar,dim=val]test:1|g",
|
||||||
"foo15:200|ms:300|ms:5|c|@0.1:6|g\nfoo15a:1|c:5|ms",
|
"foo15:200|ms:300|ms:5|c|@0.1:6|g\nfoo15a:1|c:5|ms",
|
||||||
"some_very_useful_metrics_with_quite_a_log_name:13|c",
|
"some_very_useful_metrics_with_quite_a_log_name:13|c",
|
||||||
}
|
}
|
||||||
bytesInput := make([]string, len(input)*times)
|
bytesInput := make([]string, len(input)*times)
|
||||||
|
logger := log.NewNopLogger()
|
||||||
for run := 0; run < times; run++ {
|
for run := 0; run < times; run++ {
|
||||||
for i := 0; i < len(input); i++ {
|
for i := 0; i < len(input); i++ {
|
||||||
bytesInput[run*len(input)+i] = fmt.Sprintf("run%d%s", run, input[i])
|
bytesInput[run*len(input)+i] = fmt.Sprintf("run%d%s", run, input[i])
|
||||||
|
@ -46,7 +49,15 @@ func benchmarkUDPListener(times int, b *testing.B) {
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
// there are more events than input lines, need bigger buffer
|
// there are more events than input lines, need bigger buffer
|
||||||
events := make(chan event.Events, len(bytesInput)*times*2)
|
events := make(chan event.Events, len(bytesInput)*times*2)
|
||||||
l := listener.StatsDUDPListener{EventHandler: &event.UnbufferedEventHandler{C: events}}
|
|
||||||
|
l := listener.StatsDUDPListener{
|
||||||
|
EventHandler: &event.UnbufferedEventHandler{C: events},
|
||||||
|
Logger: logger,
|
||||||
|
UDPPackets: udpPackets,
|
||||||
|
LinesReceived: linesReceived,
|
||||||
|
SamplesReceived: samplesReceived,
|
||||||
|
TagsReceived: tagsReceived,
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < times; i++ {
|
for i := 0; i < times; i++ {
|
||||||
for _, line := range bytesInput {
|
for _, line := range bytesInput {
|
||||||
|
|
|
@ -47,7 +47,6 @@ func benchmarkLineToEvents(times int, b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func BenchmarkLineToEvents1(b *testing.B) {
|
func BenchmarkLineToEvents1(b *testing.B) {
|
||||||
benchmarkLineToEvents(1, b)
|
benchmarkLineToEvents(1, b)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue