blabbermouth-librato 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 932c5b50bdea069e844d6cc71dad6dbb280bbbda
4
+ data.tar.gz: 44f75a4bd74278e527255120a6a98f16bfd7147d
5
+ SHA512:
6
+ metadata.gz: 9b2568b9a7b3da52da085bb67ae4418291a270c8d7afc5972b5673832275e25d1302ef975e0b2d15bfd560b4b1baa6a9a6eb8d4d8697489548ce8bc83f603672
7
+ data.tar.gz: 174e1d79628e528a6f51a673dc177c03d1a9047ab94ddb234ca3bcfc2934abdd00b899942c38af51f5b7d9aaa2b79af68b1e90fe78f51dbc5ecef7ae5efd216d
@@ -0,0 +1,2 @@
1
+ require 'blabbermouth'
2
+ require 'blabbermouth/gawkers/librato'
@@ -0,0 +1,67 @@
1
+ module Blabbermouth
2
+ module Gawkers
3
+ class Librato < Base
4
+ def error(key, e, *args)
5
+ data, opts, args = parse_args(*args)
6
+ librato!
7
+ ::Librato.increment(key, opts)
8
+ end
9
+
10
+ def info(key, msg=nil, *args)
11
+ data, opts, args = parse_args(*args)
12
+ librato_metrics!
13
+ begin
14
+ ::Librato::Metrics.annotate(key, msg, opts)
15
+ rescue => e
16
+ STDOUT.puts "[librato] submission failed permanently: #{e.message}"
17
+ end
18
+ end
19
+
20
+ def increment(key, by=1, *args)
21
+ data, opts, args = parse_args(*args)
22
+ librato!
23
+ ::Librato.increment(key, opts.merge({by: by}))
24
+ end
25
+
26
+ def count(key, total, *args)
27
+ data, opts, args = parse_args(*args)
28
+ librato!
29
+ ::Librato.measure(key, total, opts)
30
+ end
31
+ alias_method :gauge, :count
32
+
33
+ def time(key, duration, *args)
34
+ data, opts, args = parse_args(*args)
35
+ librato!
36
+ ::Librato.timing(key, duration, opts)
37
+ end
38
+
39
+ def flush
40
+ librato!
41
+ begin
42
+ ::Librato.tracker.flush
43
+ rescue => e
44
+ false
45
+ end
46
+ 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 gawker" 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 gawker" unless librato_metrics?
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,45 @@
1
+ module Librato
2
+ @increments = {}
3
+ @measurements = {}
4
+ @timings = {}
5
+
6
+ def self.increment(key, *args, by: 1)
7
+ @increments[key] ||= 0
8
+ @increments[key] += by
9
+ end
10
+
11
+ def self.measure(key, value, *args)
12
+ @measurements[key] ||= []
13
+ @measurements[key] << value
14
+ end
15
+
16
+ def self.timing(key, duration, *args)
17
+ @timings[key] ||= []
18
+ @timings[key] << duration
19
+ end
20
+
21
+ def self.increments
22
+ @increments
23
+ end
24
+
25
+ def self.measurements
26
+ @measurements
27
+ end
28
+
29
+ def self.timings
30
+ @timings
31
+ end
32
+
33
+ module Metrics
34
+ @annotations = {}
35
+
36
+ def self.annotate(key, msg, *args)
37
+ @annotations[key] ||= []
38
+ @annotations[key] << msg
39
+ end
40
+
41
+ def self.annotations
42
+ @annotations
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blabbermouth-librato
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Mark Rebec
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: blabbermouth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: librato-metrics
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Gawker for Blabbermouth that posts to Librato
70
+ email:
71
+ - mark@markrebec.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/blabbermouth-librato.rb
77
+ - lib/blabbermouth/gawkers/librato.rb
78
+ - spec/support/librato.rb
79
+ homepage: http://github.com/markrebec/blabbermouth
80
+ licenses: []
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.2.2
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Librato gawker for Blabbermouth
102
+ test_files:
103
+ - spec/support/librato.rb