vitals 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vitals/reporters/dns_resolving_statsd_reporter.rb +39 -0
- data/lib/vitals/reporters/statsd_reporter.rb +1 -1
- data/lib/vitals/version.rb +1 -1
- data/lib/vitals.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22251cae8ed5dfe457f58b95ab4ff44342551cb8
|
4
|
+
data.tar.gz: 81ba009c776476e8a2e92261e7d51b49a9ad6b27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6833d733be34fa74b38faa5b7eee2d49af619e1b41bd2119a4de160d5cf0f974f4144ff84298d8627fdece985f6e5400449da3043d64eb60610767a414be177
|
7
|
+
data.tar.gz: ecdabc5249ec20afef0bc8507f734cf255060a2dd21bc79e3922e7e5f86722ae2a3661074cb75f65332ff568a285daf72b4c3b8a1d565e46c19bf7dfc1957041
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'statsd-ruby'
|
2
|
+
require 'resolv'
|
3
|
+
|
4
|
+
module Vitals::Reporters
|
5
|
+
class DnsResolvingStatsdReporter < StatsdReporter
|
6
|
+
def initialize(host: 'localhost', port: 8125, format: nil)
|
7
|
+
@host = host
|
8
|
+
@port = port
|
9
|
+
@format = format
|
10
|
+
setup_statsd
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def setup_statsd
|
15
|
+
ip = @host
|
16
|
+
unless (@host =~ Resolv::AddressRegex || @host == 'localhost'.freeze)
|
17
|
+
ip, ttl = query_dns
|
18
|
+
Thread.new do
|
19
|
+
while true do
|
20
|
+
sleep ttl
|
21
|
+
previous_ip = ip
|
22
|
+
ip, ttl = query_dns
|
23
|
+
if ip != previous_ip
|
24
|
+
@statsd = Statsd.new(ip, @port)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
@statsd = Statsd.new(ip, @port)
|
30
|
+
end
|
31
|
+
|
32
|
+
def query_dns
|
33
|
+
ress = Resolv::DNS.open { |dns| dns.getresource(@host, Resolv::DNS::Resource::IN::A) }
|
34
|
+
[ress.address.to_s, ress.ttl]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
data/lib/vitals/version.rb
CHANGED
data/lib/vitals.rb
CHANGED
@@ -15,6 +15,7 @@ require 'vitals/reporters/inmem_reporter'
|
|
15
15
|
require 'vitals/reporters/console_reporter'
|
16
16
|
require 'vitals/reporters/multi_reporter'
|
17
17
|
require 'vitals/reporters/statsd_reporter'
|
18
|
+
require 'vitals/reporters/dns_resolving_statsd_reporter'
|
18
19
|
|
19
20
|
require 'vitals/formats/production_format'
|
20
21
|
require 'vitals/formats/host_last_format'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vitals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dotan Nahum
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- lib/vitals/integrations/rack/requests.rb
|
235
235
|
- lib/vitals/reporters/base_reporter.rb
|
236
236
|
- lib/vitals/reporters/console_reporter.rb
|
237
|
+
- lib/vitals/reporters/dns_resolving_statsd_reporter.rb
|
237
238
|
- lib/vitals/reporters/inmem_reporter.rb
|
238
239
|
- lib/vitals/reporters/multi_reporter.rb
|
239
240
|
- lib/vitals/reporters/statsd_reporter.rb
|