wat_catcher 0.10.8 → 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- data/README.md +26 -0
- data/lib/wat_catcher.rb +2 -0
- data/lib/wat_catcher/metrics.rb +29 -0
- data/lib/wat_catcher/report.rb +33 -0
- data/lib/wat_catcher/version.rb +1 -1
- data/wat_catcher.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 712be060f30a0d18b0801b6dfdcfff48fe5bde00
|
4
|
+
data.tar.gz: df3885aed59be97cb8136995ee4558baf571d704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79380328041b6d62094cf628aec75d91a937914cf10b4f9eb387b5ecc735041f411e856579db6f1abc1277761840972e7e941d2549d484874188d226c72a8985
|
7
|
+
data.tar.gz: 9e9f68302a48c01e6082ffb2011f788f47c906ff237cdbbecfed4b288f9c47897d8ddc86ad92771276b0115cca3a75f0426f752e5f66ffc309713f2e29d0cf43
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wat_catcher (0.10.
|
4
|
+
wat_catcher (0.10.9)
|
5
5
|
coffee-rails
|
6
6
|
httpclient
|
7
7
|
rails (>= 4.2.0)
|
8
|
+
statsd-ruby
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -76,7 +77,7 @@ GEM
|
|
76
77
|
guard (>= 2.1.0)
|
77
78
|
guard-compat (~> 1.1)
|
78
79
|
guard-compat (1.2.1)
|
79
|
-
httpclient (2.8.
|
80
|
+
httpclient (2.8.3)
|
80
81
|
i18n (0.7.0)
|
81
82
|
jasmine (2.4.0)
|
82
83
|
jasmine-core (~> 2.4)
|
@@ -173,6 +174,7 @@ GEM
|
|
173
174
|
activesupport (>= 4.0)
|
174
175
|
sprockets (>= 3.0.0)
|
175
176
|
sqlite3 (1.3.11)
|
177
|
+
statsd-ruby (1.3.0)
|
176
178
|
thor (0.19.4)
|
177
179
|
thread_safe (0.3.5)
|
178
180
|
tzinfo (1.2.2)
|
data/README.md
CHANGED
@@ -66,6 +66,32 @@ YourApp::Application.configure do
|
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
|
+
#### Adding Telemetry
|
70
|
+
In `config/wat_catcher.yml`:
|
71
|
+
|
72
|
+
```yml
|
73
|
+
production: &default
|
74
|
+
statsd_host: statsd.service.consul
|
75
|
+
statsd_port: 9125
|
76
|
+
metrics_disabled: false # defaults to true
|
77
|
+
```
|
78
|
+
|
79
|
+
Alternatively, this can be configured in `config/application.rb` or environment file (e.g. `config/environments/production.rb`).
|
80
|
+
```ruby
|
81
|
+
module YourApp
|
82
|
+
class Application < Rails::Application
|
83
|
+
WatCatcher.configuration.statsd_host = "statsd.service.consul"
|
84
|
+
WatCatcher.configuration.statsd_port = 9125
|
85
|
+
WatCatcher.configuration.metrics_disabled = false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
YourApp::Application.configure do
|
92
|
+
WatCatcher.configuration.metrics_disabled = false
|
93
|
+
end
|
94
|
+
```
|
69
95
|
|
70
96
|
### Mount the engine in your app for javascript errors
|
71
97
|
To get around cross-origin issues, an engine was created that accepts POSTs of client exceptions and puts a sidekiq
|
data/lib/wat_catcher.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module WatCatcher
|
2
|
+
class Metrics
|
3
|
+
attr_writer :host, :port
|
4
|
+
|
5
|
+
def host
|
6
|
+
@host ||= 'localhost'
|
7
|
+
end
|
8
|
+
|
9
|
+
def port
|
10
|
+
@port ||= 9125
|
11
|
+
end
|
12
|
+
|
13
|
+
def client
|
14
|
+
::Statsd.new @host, @port
|
15
|
+
end
|
16
|
+
|
17
|
+
def increment(metric, sample_rate=1)
|
18
|
+
client.increment metric, sample_rate
|
19
|
+
end
|
20
|
+
|
21
|
+
def decrement(metric, sample_rate=1)
|
22
|
+
client.increment metric, sample_rate
|
23
|
+
end
|
24
|
+
|
25
|
+
def set(metric, value, sample_rate=1)
|
26
|
+
client.set metric, value, sample_rate
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/wat_catcher/report.rb
CHANGED
@@ -9,6 +9,7 @@ module WatCatcher
|
|
9
9
|
self.user = user
|
10
10
|
send_report
|
11
11
|
log_report
|
12
|
+
instrument_report unless metrics_disabled?
|
12
13
|
end
|
13
14
|
|
14
15
|
def send_report
|
@@ -21,6 +22,38 @@ module WatCatcher
|
|
21
22
|
Rails.logger.error( "WatCatcher::error: " + base_description.tap {|x| x.delete(:rails_root) }.to_json )
|
22
23
|
end
|
23
24
|
|
25
|
+
def metrics_disabled?
|
26
|
+
WatCatcher.configuration.metrics_disabled = true if WatCatcher.configuration.metrics_disabled.nil?
|
27
|
+
WatCatcher.configuration.metrics_disabled
|
28
|
+
end
|
29
|
+
|
30
|
+
def metrics_reporter
|
31
|
+
@reporter ||= ::WatCatcher::Metrics.new
|
32
|
+
@reporter.host = WatCatcher.configuration.statsd_host
|
33
|
+
@reporter.port = WatCatcher.configuration.statsd_port
|
34
|
+
|
35
|
+
@reporter
|
36
|
+
end
|
37
|
+
|
38
|
+
def metrics_namespace
|
39
|
+
"#{base_description[:app_name]}.#{base_description[:app_env]}".downcase
|
40
|
+
end
|
41
|
+
|
42
|
+
def instrument_report
|
43
|
+
return if WatCatcher.configuration.disabled
|
44
|
+
|
45
|
+
# increment graphite counter, ':' is used to seperate metric from metric value -- therefore, replace ':' with '_'
|
46
|
+
# e.g. kairos.staging.exceptions.NoMethodError.frequency is count of `NoMethodError`s during sample period (60s)
|
47
|
+
#
|
48
|
+
# for application-aggregated
|
49
|
+
metrics_reporter.increment "#{metrics_namespace}.wat.#{exception_description[:error_class].gsub ':', '_'}.frequency"
|
50
|
+
# for server-aggregated
|
51
|
+
metrics_reporter.increment "#{metrics_namespace}.#{base_description[:hostname]}.wat.#{exception_description[:error_class].gsub ':', '_'}.frequency"
|
52
|
+
|
53
|
+
# emit an event that an exception was raised
|
54
|
+
metrics_reporter.set "#{metrics_namespace}.#{base_description[:hostname]}.wat.#{base_description[:error_class]}.occurance", base_description[:captured_at]
|
55
|
+
end
|
56
|
+
|
24
57
|
def params
|
25
58
|
{ wat: base_description
|
26
59
|
.merge(user_description)
|
data/lib/wat_catcher/version.rb
CHANGED
data/wat_catcher.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wat_catcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Constantine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: statsd-ruby
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description: Catch your wats
|
168
182
|
email:
|
169
183
|
- cconstan@gmail.com
|
@@ -186,6 +200,7 @@ files:
|
|
186
200
|
- config/routes.rb
|
187
201
|
- lib/wat_catcher.rb
|
188
202
|
- lib/wat_catcher/engine.rb
|
203
|
+
- lib/wat_catcher/metrics.rb
|
189
204
|
- lib/wat_catcher/poster.rb
|
190
205
|
- lib/wat_catcher/rack_middleware.rb
|
191
206
|
- lib/wat_catcher/railtie.rb
|