ruby-metrics-opentsdb 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby-metrics/reporters/opentsdb.rb +49 -11
- metadata +4 -4
@@ -17,10 +17,15 @@ module Metrics
|
|
17
17
|
@hostname = options[:hostname]
|
18
18
|
@port = options[:port]
|
19
19
|
@client = OpenTSDB::Client.new({:hostname => @hostname, :port => @port})
|
20
|
-
@tags = options[:tags]
|
20
|
+
@tags = options[:tags]
|
21
21
|
end
|
22
22
|
|
23
|
-
def send_data(
|
23
|
+
def send_data(opts = {})
|
24
|
+
name = opts[:name]
|
25
|
+
value = opts[:value]
|
26
|
+
units = opts[:units]
|
27
|
+
extra_tags = opts[:tags]
|
28
|
+
|
24
29
|
tsdb_data = {
|
25
30
|
:metric => name,
|
26
31
|
:timestamp => Time.now.to_i,
|
@@ -30,6 +35,12 @@ module Metrics
|
|
30
35
|
|
31
36
|
if units
|
32
37
|
tsdb_data[:tags][:units] = units
|
38
|
+
else
|
39
|
+
tsdb_data[:tags][:units] = 'none'
|
40
|
+
end
|
41
|
+
|
42
|
+
if extra_tags
|
43
|
+
tsdb_data[:tags].merge!(extra_tags)
|
33
44
|
end
|
34
45
|
|
35
46
|
@client.put(tsdb_data)
|
@@ -39,32 +50,59 @@ module Metrics
|
|
39
50
|
agent.instruments.clone.each do |name, instrument|
|
40
51
|
case instrument
|
41
52
|
when Metrics::Instruments::Counter
|
42
|
-
|
43
|
-
|
53
|
+
send_data :name => "#{name}",
|
54
|
+
:value => instrument.to_i,
|
55
|
+
:tags => instrument.tags,
|
56
|
+
:units => instrument.units
|
57
|
+
|
44
58
|
when Metrics::Instruments::Gauge
|
45
59
|
if instrument.get.is_a? Hash
|
46
60
|
instrument.get.each do |key, value|
|
47
|
-
send_data "#{name}.#{key}",
|
61
|
+
send_data :name => "#{name}.#{key}",
|
62
|
+
:value => value,
|
63
|
+
:tags => instrument.tags,
|
64
|
+
:units => instrument.units
|
48
65
|
end
|
49
66
|
else
|
50
|
-
send_data name
|
67
|
+
send_data :name => "#{name}",
|
68
|
+
:value => instrument.get,
|
69
|
+
:tags => instrument.tags,
|
70
|
+
:units => instrument.units
|
51
71
|
end
|
52
72
|
when Metrics::Instruments::Timer
|
53
73
|
rate_units = "#{instrument.units}/sec"
|
54
74
|
time_units = "sec/#{instrument.units}"
|
55
|
-
|
75
|
+
|
76
|
+
send_data :name => "#{name}.count",
|
77
|
+
:value => instrument.count,
|
78
|
+
:tags => instrument.tags,
|
79
|
+
:units => instrument.units
|
80
|
+
|
56
81
|
[:fifteen_minute_rate, :five_minute_rate, :one_minute_rate].each do |attribute|
|
57
|
-
send_data "#{name}.#{attribute}",
|
82
|
+
send_data :name => "#{name}.#{attribute}",
|
83
|
+
:value => instrument.send(attribute),
|
84
|
+
:tags => instrument.tags,
|
85
|
+
:units => rate_units
|
58
86
|
end
|
59
87
|
|
60
88
|
[:min, :max, :mean].each do |attribute|
|
61
|
-
send_data "#{name}.#{attribute}",
|
89
|
+
send_data :name => "#{name}.#{attribute}",
|
90
|
+
:value => instrument.send(attribute),
|
91
|
+
:tags => instrument.tags,
|
92
|
+
:units => time_units
|
62
93
|
end
|
63
94
|
when Metrics::Instruments::Meter
|
95
|
+
send_data :name => "#{name}.count",
|
96
|
+
:value => instrument.counted,
|
97
|
+
:tags => instrument.tags,
|
98
|
+
:units => instrument.units
|
99
|
+
|
64
100
|
rate_units = "#{instrument.units}/sec"
|
65
|
-
send_data "#{name}.count", instrument.count, instrument.units
|
66
101
|
[:fifteen_minute_rate, :five_minute_rate, :one_minute_rate, :mean_rate].each do |attribute|
|
67
|
-
send_data "#{name}.#{attribute}",
|
102
|
+
send_data :name => "#{name}.#{attribute}",
|
103
|
+
:value => instrument.send(attribute),
|
104
|
+
:tags => instrument.tags,
|
105
|
+
:units => rate_units
|
68
106
|
end
|
69
107
|
else
|
70
108
|
puts 'Unhandled instrument'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-metrics-opentsdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opentsdb
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.9.
|
37
|
+
version: 0.9.1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.9.
|
45
|
+
version: 0.9.1
|
46
46
|
description: A reporter that uses OpenTSDB to stash metric data
|
47
47
|
email:
|
48
48
|
- john@johnewart.net
|