forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatsd_spec.rb
86 lines (75 loc) · 1.67 KB
/
statsd_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require "spec_helper"
require "logstash/outputs/statsd"
require "mocha/api"
require "socket"
describe LogStash::Outputs::Statsd do
port = 4399
udp_server = UDPSocket.new
udp_server.bind("127.0.0.1", port)
describe "send metric to statsd" do
config <<-CONFIG
input {
generator {
message => "valid"
count => 1
}
}
output {
statsd {
host => "localhost"
sender => "spec"
port => #{port}
count => [ "test.valid", "0.1" ]
}
}
CONFIG
agent do
metric, *data = udp_server.recvfrom(100)
insist { metric } == "logstash.spec.test.valid:0.1|c"
end
end
describe "output a very small float" do
config <<-CONFIG
input {
generator {
message => "valid"
count => 1
}
}
output {
statsd {
host => "localhost"
sender => "spec"
port => #{port}
count => [ "test.valid", 0.000001 ]
}
}
CONFIG
agent do
metric, *data = udp_server.recvfrom(100)
insist { metric } == "logstash.spec.test.valid:0.000001|c"
end
end
describe "output a very big float" do
config <<-CONFIG
input {
generator {
message => "valid"
count => 1
}
}
output {
statsd {
host => "localhost"
sender => "spec"
port => #{port}
count => [ "test.valid", 9999999999999.01 ]
}
}
CONFIG
agent do
metric, *data = udp_server.recvfrom(100)
insist { metric } == "logstash.spec.test.valid:9999999999999.01|c"
end
end
end