Fix for issue #250

Signed-off-by: Amit Saha <amitsaha.in@gmail.com>
This commit is contained in:
Amit Saha 2019-09-09 17:23:45 +10:00
parent 8479e3d7a3
commit 028531e953
2 changed files with 13 additions and 3 deletions

View file

@ -157,6 +157,16 @@ func TestHandlePacket(t *testing.T) {
labels: map[string]string{"tag1": "bar", "tag2": "baz"},
},
},
}, {
name: "histogram with sampling",
in: "foo:0.01|h|@0.1|#tag1:bar,#tag2:baz",
out: Events{
&TimerEvent{
metricName: "foo",
value: 0.01,
labels: map[string]string{"tag1": "bar", "tag2": "baz"},
},
},
}, {
name: "datadog tag extension with multiple colons",
in: "foo:100|c|@0.1|#tag1:foo:bar",

View file

@ -389,8 +389,8 @@ samples:
for _, component := range components[2:] {
switch component[0] {
case '@':
if statType != "c" && statType != "ms" {
log.Debugln("Illegal sampling factor for non-counter metric on line", line)
if statType == "g" {
log.Debugln("Illegal sampling factor for gauge metric type on line", line)
sampleErrors.WithLabelValues("illegal_sample_factor").Inc()
continue
}
@ -405,7 +405,7 @@ samples:
if statType == "c" {
value /= samplingFactor
} else if statType == "ms" {
} else if statType == "ms" || statType == "h" {
multiplyEvents = int(1 / samplingFactor)
}
case '#':