riemann-metrics 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +165 -0
- data/Rakefile +9 -0
- data/config.ru +7 -0
- data/lib/riemann-metrics.rb +54 -0
- data/lib/riemann/metrics.rb +3 -0
- data/lib/riemann/metrics/client.rb +48 -0
- data/lib/riemann/metrics/notifications_handler.rb +35 -0
- data/lib/riemann/metrics/version.rb +5 -0
- data/riemann-metrics.gemspec +28 -0
- data/spec/functional/riemann-metrics_spec.rb +66 -0
- data/spec/internal/app/controllers/awesome_controller.rb +23 -0
- data/spec/internal/app/mailers/awesome_mailer.rb +11 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/environments/test.rb +48 -0
- data/spec/internal/config/initializers/riemann_metrics.rb +15 -0
- data/spec/internal/config/routes.rb +5 -0
- data/spec/internal/db/schema.rb +3 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +8 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0313555f2665a8a2beb9e5cdd046b444c87cdd45
|
4
|
+
data.tar.gz: d00791de8c5f51d1c1c3dbca19f228d7261269fd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ee31d24b84664968d5e519f90ab4687faf7f9a98ebf0a722d881bd0edc95df1208b4f967047f1581a90548301eff061a2198d6c8870b5ba4e6e25e2e69bb557
|
7
|
+
data.tar.gz: ed41c9d6d156c2090712eac94633253a46b706d7bd455c977701b723bf0e19693555da7688ccc11d1cdfeae70f32eb78afd8bb5b7068da05da74a939d245fc37
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 George Sheppard
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
# Riemann::Metrics
|
2
|
+
|
3
|
+
Riemann::Metrics is an opinionated Rails engine for forwarding ActiveSupport::Notifications to a Riemann server. It's opinionated in that it makes some assumptions about what a Riemann event should look like.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'riemann-metrics'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install riemann-metrics
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
Create an initializer in your application's config/initializers directory.
|
22
|
+
|
23
|
+
````ruby
|
24
|
+
MyApp::Application.configure do
|
25
|
+
config.riemann_metrics.enabled = true # set to false to disable metrics collection
|
26
|
+
config.riemann_metrics.service_name = 'my-rails-app' # the name of your application / service
|
27
|
+
config.riemann_metrics.host = 'localhost' # the host of your Riemann server
|
28
|
+
config.riemann_metrics.port = 5555 # the port of your Riemann server
|
29
|
+
config.riemann_metrics.ttl = 5 # the TTL for metrics sent to Riemann
|
30
|
+
config.riemann_metrics.riemann_env = Rails.env # environment to tag metrics with, defaults to Rails.env
|
31
|
+
end
|
32
|
+
````
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
### Rails Metrics
|
37
|
+
|
38
|
+
By default Riemann::Metrics will subscribe to the following channels provided by ActiveSupport::Notifications:
|
39
|
+
|
40
|
+
* process_action.action_controller
|
41
|
+
|
42
|
+
The following metrics will be generated for a given process_action.action_controller event:
|
43
|
+
|
44
|
+
http_status - the HTTP status of a given request
|
45
|
+
````
|
46
|
+
{
|
47
|
+
:host=>"Georges-MacBook-Air.local",
|
48
|
+
:state=>"ok",
|
49
|
+
:metric=>200,
|
50
|
+
:ttl=>5,
|
51
|
+
:tags=>["Api::InstitutionsController", "index", "http_status", "development"],
|
52
|
+
:service=>"my-rails-app.Api::InstitutionsController.index.http_status"
|
53
|
+
}
|
54
|
+
````
|
55
|
+
|
56
|
+
view_runtime - the time taken rendering a view for a given request
|
57
|
+
````
|
58
|
+
{
|
59
|
+
:host=>"Georges-MacBook-Air.local",
|
60
|
+
:state=>"ok",
|
61
|
+
:metric=>0.225,
|
62
|
+
:ttl=>5,
|
63
|
+
:tags=>["Api::InstitutionsController", "index", "view_runtime", "development"],
|
64
|
+
:service=>"my-rails-app.Api::InstitutionsController.index.view_runtime"
|
65
|
+
}
|
66
|
+
````
|
67
|
+
|
68
|
+
request_runtime - the total time taking handling a given request
|
69
|
+
````
|
70
|
+
{
|
71
|
+
:host=>"Georges-MacBook-Air.local",
|
72
|
+
:state=>"ok",
|
73
|
+
:metric=>159.704,
|
74
|
+
:ttl=>5,
|
75
|
+
:tags=>["Api::InstitutionsController", "index", "request_runtime", "development"],
|
76
|
+
:service=>"my-rails-app.Api::InstitutionsController.index.total_time"
|
77
|
+
}
|
78
|
+
````
|
79
|
+
|
80
|
+
db_runtime - the time taken doing database queries for a given request
|
81
|
+
````
|
82
|
+
{
|
83
|
+
:host=>"Georges-MacBook-Air.local",
|
84
|
+
:state=>"ok",
|
85
|
+
:metric=>39.528999999999996,
|
86
|
+
:ttl=>5,
|
87
|
+
:tags=>["Api::InstitutionsController", "index", "db_runtime", "development"],
|
88
|
+
:service=>"my-rails-app.Api::InstitutionsController.index.db_runtime"
|
89
|
+
}
|
90
|
+
````
|
91
|
+
|
92
|
+
The state will be 'ok' unless an exception is present in the ActiveSupport::Notification payload, in which case it will be 'critical'.
|
93
|
+
|
94
|
+
* deliver.action_mailer
|
95
|
+
|
96
|
+
The following metric will be generated for a deliver.action_mailer event:
|
97
|
+
|
98
|
+
````
|
99
|
+
{
|
100
|
+
:host=>"Georges-MacBook-Air.local",
|
101
|
+
:state=>"ok",
|
102
|
+
:metric=>2000.0330000000001,
|
103
|
+
:ttl=>5,
|
104
|
+
:tags=>["AwesomeMailer", "email_send_runtime", "test"],
|
105
|
+
:service=>"Rails.AwesomeMailer.email_send_runtime"
|
106
|
+
}
|
107
|
+
````
|
108
|
+
|
109
|
+
email_send_runtime - the time taken to send a given email
|
110
|
+
|
111
|
+
The state will be 'ok' unless an exception is present in the ActiveSupport::Notification payload, in which case it will be 'critical'.
|
112
|
+
|
113
|
+
### Custom Metrics
|
114
|
+
|
115
|
+
You can use Riemann::Metrics to collect your own custom metrics.
|
116
|
+
|
117
|
+
#### Generate Metric
|
118
|
+
|
119
|
+
````ruby
|
120
|
+
Riemann::Metrics.instrument "my-awesome-metric", ["custom","tag"], "ok", 1
|
121
|
+
````
|
122
|
+
|
123
|
+
Will generate a metric of 1, for the 'my-awesome-metric' channel with "custom" and "tag" as tags. The state will be 'ok'.
|
124
|
+
|
125
|
+
````ruby
|
126
|
+
Riemann::Metrics.instrument "my-awesome-timed-metric", ["custom","tag"], "ok", 1 do
|
127
|
+
sleep 2
|
128
|
+
end
|
129
|
+
````
|
130
|
+
|
131
|
+
Will generate a timing metric for the given block, for the 'my-awesome-metric' channel with "custom" and "tag" as tags. The state will be 'ok'.
|
132
|
+
|
133
|
+
*note* the supplied metric of 1 will be ignored and the time taken to execute the block will be used instead.
|
134
|
+
|
135
|
+
#### Subscribe to the Metric
|
136
|
+
|
137
|
+
````ruby
|
138
|
+
Riemann::Metrics.subscribe "my-awesome-metric" do |client, channel, start, finish, id, payload|
|
139
|
+
tags = payload[:tags]
|
140
|
+
state = payload[:state]
|
141
|
+
metric = payload[:metric]
|
142
|
+
|
143
|
+
client.gauge tags, state, metric, "my-awesome-metric"
|
144
|
+
end
|
145
|
+
````
|
146
|
+
|
147
|
+
````ruby
|
148
|
+
Riemann::Metrics.subscribe "my-awesome-timed-metric" do |client, channel, start, finish, id, payload|
|
149
|
+
tags = payload[:tags]
|
150
|
+
state = payload[:state]
|
151
|
+
total_time = ( finish - start ) * 1000
|
152
|
+
|
153
|
+
client.gauge tags, state, total_time, "my-awesome-timed-metric"
|
154
|
+
end
|
155
|
+
````
|
156
|
+
|
157
|
+
The 'subscription' to a given metric collects events generated from Riemann::Metrics.instrument and pushes them to Riemann.
|
158
|
+
|
159
|
+
## Contributing
|
160
|
+
|
161
|
+
1. Fork it
|
162
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
163
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
164
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
165
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/config.ru
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'active_support/notifications'
|
2
|
+
require "riemann/metrics"
|
3
|
+
|
4
|
+
module Riemann
|
5
|
+
module Metrics
|
6
|
+
class Engine < Rails::Engine
|
7
|
+
attr_reader :client, :handler
|
8
|
+
|
9
|
+
config.riemann_metrics = ActiveSupport::OrderedOptions.new
|
10
|
+
|
11
|
+
config.riemann_metrics.enabled = true
|
12
|
+
config.riemann_metrics.host = 'localhost'
|
13
|
+
config.riemann_metrics.port = 5555
|
14
|
+
config.riemann_metrics.service_name = 'Rails'
|
15
|
+
config.riemann_metrics.ttl = 5
|
16
|
+
config.riemann_metrics.riemann_env = Rails.env
|
17
|
+
|
18
|
+
initializer "riemann_metrics.initialise" do |app|
|
19
|
+
app_cfg = app.config.riemann_metrics
|
20
|
+
Riemann::Metrics.initialize(app_cfg.host, app_cfg.port, app_cfg.service_name, app_cfg.riemann_env, app_cfg.ttl) if app_cfg.enabled
|
21
|
+
end
|
22
|
+
|
23
|
+
initializer "riemann_metrics.subscribe" do |app|
|
24
|
+
ActiveSupport::Notifications.subscribe( /[^!]$/ ) do |*args|
|
25
|
+
Riemann::Metrics.gauge args
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.instrument channel, tags, state, metric, &block
|
32
|
+
ActiveSupport::Notifications.instrument(channel, tags: tags, state: state, metric: metric) do
|
33
|
+
block.call if block_given?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.subscribe channel, &block
|
38
|
+
ActiveSupport::Notifications.subscribe(channel) do |*args|
|
39
|
+
block.call(@client, *args)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.initialize(host, port, service_name, riemann_env, ttl)
|
44
|
+
@client = Riemann::Metrics::Client.new(host, port, service_name, riemann_env, ttl)
|
45
|
+
@handler = Riemann::Metrics::NotificationsHandler.new(@client)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.gauge args
|
49
|
+
handler_method = args[0].gsub(".","_").to_sym
|
50
|
+
@handler.send handler_method, *args if @handler.respond_to?(handler_method)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'riemann'
|
2
|
+
|
3
|
+
module Riemann
|
4
|
+
module Metrics
|
5
|
+
class Client
|
6
|
+
|
7
|
+
OK = "ok"
|
8
|
+
CRITICAL = "critical"
|
9
|
+
WARNING = "warning"
|
10
|
+
STATES = [OK,CRITICAL,WARNING]
|
11
|
+
|
12
|
+
TTL = 10
|
13
|
+
|
14
|
+
def initialize host, port, service_name, riemann_env, ttl
|
15
|
+
@host = host
|
16
|
+
@port = port
|
17
|
+
@service_name = service_name
|
18
|
+
@ttl = ttl || TTL
|
19
|
+
@riemann_env = riemann_env || 'none'
|
20
|
+
@hostname = get_hostname
|
21
|
+
end
|
22
|
+
|
23
|
+
def client
|
24
|
+
@riemann_client ||= Riemann::Client.new(host: @host, port: @port)
|
25
|
+
end
|
26
|
+
|
27
|
+
def gauge tags, state, metric, service='', description=nil
|
28
|
+
event = {
|
29
|
+
host: @hostname,
|
30
|
+
state: state,
|
31
|
+
metric: metric,
|
32
|
+
ttl: @ttl,
|
33
|
+
tags: (tags.dup << @riemann_env),
|
34
|
+
service: "#{@service_name}.#{service}"
|
35
|
+
}
|
36
|
+
event[:description] = description if description
|
37
|
+
client << event
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_hostname
|
41
|
+
`hostname`.strip
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Riemann
|
2
|
+
module Metrics
|
3
|
+
class NotificationsHandler
|
4
|
+
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
def initialize client
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
def total_time start, finish
|
12
|
+
( finish - start ) * 1000
|
13
|
+
end
|
14
|
+
|
15
|
+
def process_action_action_controller channel, start, finish, id, payload
|
16
|
+
tags = [payload[:controller], payload[:action]]
|
17
|
+
service_name = tags.join(".")
|
18
|
+
state = !payload[:exception].nil? ? Riemann::Metrics::Client::CRITICAL : Riemann::Metrics::Client::OK
|
19
|
+
client.gauge (tags.dup << 'http_status'), state, payload[:status], "#{service_name}.http_status"
|
20
|
+
client.gauge (tags.dup << 'view_runtime'), state, payload[:view_runtime], "#{service_name}.view_runtime"
|
21
|
+
client.gauge (tags.dup << 'request_runtime'), state, total_time(start, finish), "#{service_name}.total_time"
|
22
|
+
client.gauge (tags.dup << 'db_runtime'), state, payload[:db_runtime], "#{service_name}.db_runtime"
|
23
|
+
end
|
24
|
+
|
25
|
+
def deliver_action_mailer channel, start, finish, id, payload
|
26
|
+
tags = [ payload[:mailer] ]
|
27
|
+
state = !payload[:exception].nil? ? Riemann::Metrics::Client::CRITICAL : Riemann::Metrics::Client::OK
|
28
|
+
client.gauge (tags.dup << 'email_send_runtime'), state, total_time(start, finish), "#{payload[:mailer]}.email_send_runtime"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'riemann/metrics/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "riemann-metrics"
|
8
|
+
spec.version = Riemann::Metrics::VERSION
|
9
|
+
spec.authors = ["George Sheppard"]
|
10
|
+
spec.email = ["g.sheppard@digital-science.com"]
|
11
|
+
spec.description = %q{Forwards ActiveSupport::Notifications to a Riemann server}
|
12
|
+
spec.summary = %q{Forwards ActiveSupport::Notifications to a Riemann server}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rails"
|
22
|
+
spec.add_dependency "riemann-client"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec-rails"
|
27
|
+
spec.add_development_dependency 'combustion', '~> 0.5.1'
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AwesomeController, :type => :controller do
|
4
|
+
|
5
|
+
context 'given a rails application' do
|
6
|
+
|
7
|
+
it 'should collect metrics for process_action_action_controller' do
|
8
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
9
|
+
["AwesomeController", "index", "http_status"],
|
10
|
+
"ok",
|
11
|
+
200,
|
12
|
+
"AwesomeController.index.http_status"
|
13
|
+
)
|
14
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
15
|
+
["AwesomeController", "index", "view_runtime"],
|
16
|
+
"ok",
|
17
|
+
anything(),
|
18
|
+
"AwesomeController.index.view_runtime"
|
19
|
+
)
|
20
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
21
|
+
["AwesomeController", "index", "request_runtime"],
|
22
|
+
"ok",
|
23
|
+
anything(),
|
24
|
+
"AwesomeController.index.total_time"
|
25
|
+
)
|
26
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
27
|
+
["AwesomeController", "index", "db_runtime"],
|
28
|
+
"ok",
|
29
|
+
nil,
|
30
|
+
"AwesomeController.index.db_runtime"
|
31
|
+
)
|
32
|
+
|
33
|
+
get 'index'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should collect metrics for deliver_action_mailer' do
|
37
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
38
|
+
["AwesomeMailer", "email_send_runtime"],
|
39
|
+
"ok",
|
40
|
+
anything(),
|
41
|
+
"AwesomeMailer.email_send_runtime"
|
42
|
+
)
|
43
|
+
|
44
|
+
get 'send_email'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should allow for custom metric collection' do
|
48
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
49
|
+
["custom", "tag"],
|
50
|
+
"ok",
|
51
|
+
1,
|
52
|
+
"my-awesome-metric"
|
53
|
+
)
|
54
|
+
Riemann::Metrics::Client.any_instance.should_receive(:gauge).with(
|
55
|
+
["custom", "tag"],
|
56
|
+
"ok",
|
57
|
+
anything(),
|
58
|
+
"my-awesome-timed-metric"
|
59
|
+
)
|
60
|
+
|
61
|
+
get 'custom_metrics'
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class AwesomeController < ActionController::Base
|
2
|
+
|
3
|
+
def index
|
4
|
+
render :text => "OK"
|
5
|
+
end
|
6
|
+
|
7
|
+
def send_email
|
8
|
+
mail = AwesomeMailer.welcome
|
9
|
+
mail.deliver
|
10
|
+
|
11
|
+
render :text => "OK"
|
12
|
+
end
|
13
|
+
|
14
|
+
def custom_metrics
|
15
|
+
Riemann::Metrics.instrument "my-awesome-metric", ["custom","tag"], "ok", 1
|
16
|
+
Riemann::Metrics.instrument "my-awesome-timed-metric", ["custom","tag"], "ok", 1 do
|
17
|
+
sleep 2
|
18
|
+
end
|
19
|
+
|
20
|
+
render :text => "OK"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class CustomDelivery
|
2
|
+
|
3
|
+
def initialize(*)
|
4
|
+
end
|
5
|
+
|
6
|
+
def deliver!(mail)
|
7
|
+
Riemann::Metrics.gauge ["deliver.action_mailer", Time.now-2.seconds, Time.now, nil, {:mailer=>"AwesomeMailer", :message_id=>nil, :subject=>"We like to spamalot!", :to=>["text@example.com"], :from=>["no-reply@example.com"], :date=>nil, :mail=>"Date: Mon, 09 Sep 2013 16:29:27 +0100\r\nFrom: no-reply@example.com\r\nTo: text@example.com\r\nMessage-ID: <522de957a8245_93363fcfb88606d873096@Georges-MacBook-Air.local.mail>\r\nSubject: We like to spamalot!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nHello"}]
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
Combustion::Application.configure do
|
13
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
14
|
+
|
15
|
+
# The test environment is used exclusively to run your application's
|
16
|
+
# test suite. You never need to work with it otherwise. Remember that
|
17
|
+
# your test database is "scratch space" for the test suite and is wiped
|
18
|
+
# and recreated between test runs. Don't rely on the data there!
|
19
|
+
config.cache_classes = true
|
20
|
+
|
21
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
22
|
+
# just for the purpose of running a single test. If you are using a tool that
|
23
|
+
# preloads Rails for running tests, you may have to set it to true.
|
24
|
+
config.eager_load = false
|
25
|
+
|
26
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
27
|
+
config.serve_static_assets = true
|
28
|
+
config.static_cache_control = "public, max-age=3600"
|
29
|
+
|
30
|
+
# Show full error reports and disable caching.
|
31
|
+
config.consider_all_requests_local = true
|
32
|
+
config.action_controller.perform_caching = false
|
33
|
+
|
34
|
+
# Raise exceptions instead of rendering exception templates.
|
35
|
+
config.action_dispatch.show_exceptions = false
|
36
|
+
|
37
|
+
# Disable request forgery protection in test environment.
|
38
|
+
config.action_controller.allow_forgery_protection = false
|
39
|
+
|
40
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
41
|
+
# The :test delivery method accumulates sent emails in the
|
42
|
+
# ActionMailer::Base.deliveries array.
|
43
|
+
config.action_mailer.perform_deliveries = true
|
44
|
+
config.action_mailer.delivery_method = CustomDelivery
|
45
|
+
|
46
|
+
# Print deprecation notices to the stderr.
|
47
|
+
config.active_support.deprecation = :stderr
|
48
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Riemann::Metrics.subscribe "my-awesome-metric" do |client, channel, start, finish, id, payload|
|
2
|
+
tags = payload[:tags]
|
3
|
+
state = payload[:state]
|
4
|
+
metric = payload[:metric]
|
5
|
+
|
6
|
+
client.gauge tags, state, metric, "my-awesome-metric"
|
7
|
+
end
|
8
|
+
|
9
|
+
Riemann::Metrics.subscribe "my-awesome-timed-metric" do |client, channel, start, finish, id, payload|
|
10
|
+
tags = payload[:tags]
|
11
|
+
state = payload[:state]
|
12
|
+
total_time = ( finish - start ) * 1000
|
13
|
+
|
14
|
+
client.gauge tags, state, total_time, "my-awesome-timed-metric"
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riemann-metrics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- George Sheppard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
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: riemann-client
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: combustion
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.5.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.5.1
|
97
|
+
description: Forwards ActiveSupport::Notifications to a Riemann server
|
98
|
+
email:
|
99
|
+
- g.sheppard@digital-science.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .ruby-version
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- config.ru
|
111
|
+
- lib/riemann-metrics.rb
|
112
|
+
- lib/riemann/metrics.rb
|
113
|
+
- lib/riemann/metrics/client.rb
|
114
|
+
- lib/riemann/metrics/notifications_handler.rb
|
115
|
+
- lib/riemann/metrics/version.rb
|
116
|
+
- riemann-metrics.gemspec
|
117
|
+
- spec/functional/riemann-metrics_spec.rb
|
118
|
+
- spec/internal/app/controllers/awesome_controller.rb
|
119
|
+
- spec/internal/app/mailers/awesome_mailer.rb
|
120
|
+
- spec/internal/config/database.yml
|
121
|
+
- spec/internal/config/environments/test.rb
|
122
|
+
- spec/internal/config/initializers/riemann_metrics.rb
|
123
|
+
- spec/internal/config/routes.rb
|
124
|
+
- spec/internal/db/schema.rb
|
125
|
+
- spec/internal/log/.gitignore
|
126
|
+
- spec/internal/public/favicon.ico
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
homepage: ''
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.0.3
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: Forwards ActiveSupport::Notifications to a Riemann server
|
152
|
+
test_files:
|
153
|
+
- spec/functional/riemann-metrics_spec.rb
|
154
|
+
- spec/internal/app/controllers/awesome_controller.rb
|
155
|
+
- spec/internal/app/mailers/awesome_mailer.rb
|
156
|
+
- spec/internal/config/database.yml
|
157
|
+
- spec/internal/config/environments/test.rb
|
158
|
+
- spec/internal/config/initializers/riemann_metrics.rb
|
159
|
+
- spec/internal/config/routes.rb
|
160
|
+
- spec/internal/db/schema.rb
|
161
|
+
- spec/internal/log/.gitignore
|
162
|
+
- spec/internal/public/favicon.ico
|
163
|
+
- spec/spec_helper.rb
|