blabbermouth-librato 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blabbermouth/librato/bystander.rb +5 -25
- data/spec/blabbermouth/librato/bystander_spec.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd5c9d97526f0fad88c63830b49e8569c37063e4
|
4
|
+
data.tar.gz: 3169517d85dccc74227f36ef5d77d9908337b87b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da781e551f65dcb0797a2f222f391da0d13318ba6b3c229c9cddea8a04a4c5405770caeb0f866ab3f8caa236805a4e9968da1893cb59da08c7da69c5f1742085
|
7
|
+
data.tar.gz: 0209f2eb0969d43cf029e3f50bd8254fb33943cbf7893d5c9171e0827bd1fa2050f1a653cc7a0c6e999aff293c054833a18912484864506837257b17a38bb003
|
@@ -3,13 +3,11 @@ module Blabbermouth
|
|
3
3
|
class Librato < Base
|
4
4
|
def error(key, e, *args)
|
5
5
|
data, opts, args = parse_args(*args)
|
6
|
-
librato!
|
7
6
|
::Librato.increment(key, opts)
|
8
7
|
end
|
9
8
|
|
10
|
-
def
|
9
|
+
def annotate(key, msg=nil, *args)
|
11
10
|
data, opts, args = parse_args(*args)
|
12
|
-
librato_metrics!
|
13
11
|
begin
|
14
12
|
::Librato::Metrics.annotate(key, msg, opts)
|
15
13
|
rescue => e
|
@@ -17,51 +15,33 @@ module Blabbermouth
|
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
18
|
+
def info(key, msg=nil, *args)
|
19
|
+
increment(key, 1, *args)
|
20
|
+
end
|
21
|
+
|
20
22
|
def increment(key, by=1, *args)
|
21
23
|
data, opts, args = parse_args(*args)
|
22
|
-
librato!
|
23
24
|
::Librato.increment(key, opts.merge({by: by}))
|
24
25
|
end
|
25
26
|
|
26
27
|
def count(key, total, *args)
|
27
28
|
data, opts, args = parse_args(*args)
|
28
|
-
librato!
|
29
29
|
::Librato.measure(key, total, opts)
|
30
30
|
end
|
31
31
|
alias_method :gauge, :count
|
32
32
|
|
33
33
|
def time(key, duration, *args)
|
34
34
|
data, opts, args = parse_args(*args)
|
35
|
-
librato!
|
36
35
|
::Librato.timing(key, duration, opts)
|
37
36
|
end
|
38
37
|
|
39
38
|
def flush
|
40
|
-
librato!
|
41
39
|
begin
|
42
40
|
::Librato.tracker.flush
|
43
41
|
rescue => e
|
44
42
|
false
|
45
43
|
end
|
46
44
|
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
|
50
|
-
def librato?
|
51
|
-
defined?(::Librato)
|
52
|
-
end
|
53
|
-
|
54
|
-
def librato_metrics?
|
55
|
-
librato? && defined?(::Librato::Metrics)
|
56
|
-
end
|
57
|
-
|
58
|
-
def librato!
|
59
|
-
raise "You must require and configure the librato-metrics gem to use it as a bystander" unless librato?
|
60
|
-
end
|
61
|
-
|
62
|
-
def librato_metrics!
|
63
|
-
raise "You must require and configure the librato-metrics gem to use it as a bystander" unless librato_metrics?
|
64
|
-
end
|
65
45
|
end
|
66
46
|
end
|
67
47
|
end
|
@@ -9,10 +9,17 @@ RSpec.describe Blabbermouth::Bystanders::Librato do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
describe '#annotate' do
|
13
|
+
it 'posts to librato' do
|
14
|
+
subject.annotate('test.annotate', 'test')
|
15
|
+
expect(Librato::Metrics.annotations['test.annotate']).to include('test')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
12
19
|
describe '#info' do
|
13
20
|
it 'posts to librato' do
|
14
21
|
subject.info('test.info', 'test')
|
15
|
-
expect(Librato
|
22
|
+
expect(Librato.increments['test.info']).to eql(1)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|