dogcatcher 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +27 -8
- data/lib/dogcatcher/config.rb +13 -0
- data/lib/dogcatcher/notifier.rb +32 -10
- data/lib/dogcatcher/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDRmOTVkOGFmMTM2OWU3Mzc2MzY4ZjhlM2Q5YzY4ZDc2NDk4ZWI2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTg4NTgyNWM5NGI0OTliZDE5NTUwNzc2MDMwOTNhNDFiNzQ2NDkzZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzRjODRlOTc5NDJhOGYyMThkOWI3ZWRhNDNmMjQzMWY5OWE0MDQ1ZTI5YzZl
|
10
|
+
MzQwZWRkMzFlNmRhNzZlMDA2Mjc0NTI4Mjc2MzE2N2RiYTQxNzcwZjA5Y2Vj
|
11
|
+
M2IwMGVhNzU5M2MzMjFlN2IyNGQzM2NiYzAwYmJkN2ZmNjAzNmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjVkODgzZTlkN2NhY2RkOTY2ZTVkNTdlZGIxNDI4YzMyNmMxYTc3MTk4M2Nh
|
14
|
+
Yzg3MTk3YzYxYzY3ZDZkNDBhMjRjNDQ0OTRmNDUzNmQ3ZDg5YTM4OGQ1MmM4
|
15
|
+
ZWE4MjZhZTU3MGU0OGY3ZjJmMTYyNDFlZDExMjBiNDI5Y2RlZWY=
|
data/README.md
CHANGED
@@ -56,9 +56,9 @@ end
|
|
56
56
|
|
57
57
|
## Configuration
|
58
58
|
|
59
|
-
By default Dogcatcher will send
|
60
|
-
specifying a Datadog API key, Dogcatcher will switch to sending
|
61
|
-
Datadog API instead.
|
59
|
+
By default Dogcatcher will send metric and event data to statsd running on the
|
60
|
+
local host. By specifying a Datadog API key, Dogcatcher will switch to sending
|
61
|
+
events to the Datadog API instead.
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
Dogcatcher.configure do |c|
|
@@ -66,8 +66,8 @@ Dogcatcher.configure do |c|
|
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
|
-
Since the default approach is to send
|
70
|
-
available to explicitly control where the
|
69
|
+
Since the default approach is to send data to one or the other, options are
|
70
|
+
available to explicitly control where the data is sent.
|
71
71
|
|
72
72
|
```ruby
|
73
73
|
Dogcatcher.configure do |c|
|
@@ -76,7 +76,26 @@ Dogcatcher.configure do |c|
|
|
76
76
|
end
|
77
77
|
```
|
78
78
|
|
79
|
-
|
79
|
+
By default Dogcatcher will send both metrics and events, but these can be
|
80
|
+
disabled individually.
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
Dogcatcher.configure do |c|
|
84
|
+
c.send_metric = false
|
85
|
+
c.send_event = false
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
Metrics will be sent with a default name of `dogcatcher.errors.count`, this can
|
90
|
+
be customized by setting the `metric_name` configurable.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
Dogcatcher.configure do |c|
|
94
|
+
c.metric_name = 'my_app.errors.count'
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
The host and port that statsd data is sent to can be configured like so.
|
80
99
|
|
81
100
|
```ruby
|
82
101
|
Dogcatcher.configure do |c|
|
@@ -86,7 +105,7 @@ end
|
|
86
105
|
```
|
87
106
|
|
88
107
|
An optional program name can be specified to help distinguish between multiple
|
89
|
-
applications. This will appear in the event title.
|
108
|
+
applications. This will appear in the event title and as a tag on the metric.
|
90
109
|
|
91
110
|
```ruby
|
92
111
|
Dogcatcher.configure do |c|
|
@@ -116,7 +135,7 @@ Dogcatcher.configure do |c|
|
|
116
135
|
end
|
117
136
|
```
|
118
137
|
|
119
|
-
Custom tags can be sent with exception
|
138
|
+
Custom tags can be sent with exception data by adding them to the config.
|
120
139
|
|
121
140
|
```ruby
|
122
141
|
Dogcatcher.configure do |c|
|
data/lib/dogcatcher/config.rb
CHANGED
@@ -23,6 +23,14 @@ module Dogcatcher
|
|
23
23
|
attr_accessor :use_dogapi
|
24
24
|
attr_accessor :use_statsd
|
25
25
|
|
26
|
+
# When true, a metric will be sent via the enabled method.
|
27
|
+
attr_accessor :send_metric
|
28
|
+
# When true, an event will be sent via the enabled method.
|
29
|
+
attr_accessor :send_event
|
30
|
+
|
31
|
+
# Name of the metric that will be sent
|
32
|
+
attr_accessor :metric_name
|
33
|
+
|
26
34
|
# When enabled it will add tags for each +gem_name:version+ found in the
|
27
35
|
# backtrace.
|
28
36
|
#
|
@@ -37,12 +45,17 @@ module Dogcatcher
|
|
37
45
|
# Custom tags to send with exception events
|
38
46
|
attr_accessor :custom_tags
|
39
47
|
|
48
|
+
DEFAULT_METRIC_NAME = 'dogcatcher.errors.count'
|
49
|
+
|
40
50
|
def initialize
|
41
51
|
@statsd_host = '127.0.0.1'
|
42
52
|
@statsd_port = 8125
|
43
53
|
@gem_tags = true
|
44
54
|
@backtrace_cleaner = ActiveSupport::BacktraceCleaner.new
|
45
55
|
@custom_tags = []
|
56
|
+
@send_metric = true
|
57
|
+
@send_event = true
|
58
|
+
@metric_name = DEFAULT_METRIC_NAME
|
46
59
|
end
|
47
60
|
|
48
61
|
# Adds a backtrace filter. The given line in the backtrace will be replaced
|
data/lib/dogcatcher/notifier.rb
CHANGED
@@ -10,29 +10,51 @@ module Dogcatcher
|
|
10
10
|
#
|
11
11
|
# @param [Dogcatcher::Notice]
|
12
12
|
def notify(notice)
|
13
|
-
|
14
|
-
|
13
|
+
if @config.use_dogapi?
|
14
|
+
notify_dogapi_event(notice) if @config.send_event
|
15
|
+
notify_dogapi_metric(notice) if @config.send_metric
|
16
|
+
end
|
17
|
+
if @config.use_statsd?
|
18
|
+
notify_statsd_event(notice) if @config.send_event
|
19
|
+
notify_statsd_metric(notice) if @config.send_metric
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
private
|
18
24
|
|
25
|
+
def dogapi_client
|
26
|
+
@dogapi_client ||= Dogapi::Client.new(@config.api_key)
|
27
|
+
end
|
28
|
+
|
29
|
+
def statsd_client
|
30
|
+
@statsd_client = Statsd.new(@config.statsd_host, @config.statsd_port)
|
31
|
+
end
|
32
|
+
|
19
33
|
# @param [Dogcatcher::Notice]
|
20
|
-
def
|
34
|
+
def notify_dogapi_event(notice)
|
21
35
|
event = Dogapi::Event.new(notice.message,
|
22
36
|
msg_title: notice.title,
|
23
37
|
tags: notice.tags,
|
24
38
|
alert_type: 'error')
|
39
|
+
dogapi_client.emit_event(event)
|
40
|
+
end
|
25
41
|
|
26
|
-
|
42
|
+
# @param [Dogcatcher::Notice]
|
43
|
+
def notify_dogapi_metric(notice)
|
44
|
+
dogapi_client.emit_point(@config.metric_name, 1, tags: notice.tags)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param [Dogcatcher::Notice]
|
48
|
+
def notify_statsd_event(notice)
|
49
|
+
statsd_client.event(notice.title,
|
50
|
+
notice.message,
|
51
|
+
tags: notice.tags,
|
52
|
+
alert_type: 'error')
|
27
53
|
end
|
28
54
|
|
29
55
|
# @param [Dogcatcher::Notice]
|
30
|
-
def
|
31
|
-
|
32
|
-
client.event(notice.title,
|
33
|
-
notice.message,
|
34
|
-
tags: notice.tags,
|
35
|
-
alert_type: 'error')
|
56
|
+
def notify_statsd_metric(notice)
|
57
|
+
statsd_client.count(@config.metric_name, 1, tags: notice.tags)
|
36
58
|
end
|
37
59
|
end
|
38
60
|
end
|
data/lib/dogcatcher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogcatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Vidulich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|