exception_dog 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dba9c5920bdfc277211b1438d705ae428d140ac
4
- data.tar.gz: 510cb625d0d1a6c954433786f20c71dd7ca4eaa5
3
+ metadata.gz: 904ce6bb6158fc97f07feb5a9490ed02bcd7d4fe
4
+ data.tar.gz: b128b7b68a3da01902606645b847db16fd9749e8
5
5
  SHA512:
6
- metadata.gz: f93d08ba1f74f37f9953ddd2c1d643fffcccc9e35acc379a50b108573a2a337246bbc75e324b640955ae6b316cff565cc398eedb14df8d1735f244a5515be08e
7
- data.tar.gz: 11b0eaa60a752fce420f0223ad185d08eca59ead627b0c8cdebf7255127f070d7b013441313cbddd7bf9361d5145ad362ca1a6052a2f1f23a0ec9822d6480a4e
6
+ metadata.gz: f4fa837f68fae81db7cf59a2d51e8e585a57cb8d04e959d84d437dbaf1e681a1055f7f00d1d547fbcec0279b42f89164d3b0a9ea1706043089c8354e961634d7
7
+ data.tar.gz: b03f0cdc233b3774d0fbd6af36c3c6e71e2e2d69c3c83a353bffdc655a8e9f0ab25b6fd23cf0efca867e0aede18e1df181920d96f86ce4bf6ff3270a1862d8f1
data/README.md CHANGED
@@ -15,7 +15,7 @@ gem 'exception_dog'
15
15
  `exception_dog` can be configured to use the datadog agent or the public cloud API.
16
16
  You can configure in an initialiser, for example: in a file `config/initializers/exception_dog.rb`
17
17
 
18
- Agent Configuration Example
18
+ Datadog Agent Configuration Example
19
19
  ```
20
20
  ExceptionDog.configure do |config|
21
21
  config.environment = ENV["RAILS_ENV"]
@@ -24,10 +24,11 @@ ExceptionDog.configure do |config|
24
24
  config.agent_port = 8125
25
25
  config.logger = Rails.logger
26
26
  config.service_name = Rails.application.class.parent.name.underscore
27
+ config.ignore_exceptions = ["ActionController::RoutingError"]
27
28
  end
28
29
  ```
29
30
 
30
- Cloud API configuration
31
+ Datadog API configuration
31
32
 
32
33
  ```
33
34
  ExceptionDog.configure do |config|
@@ -36,6 +37,7 @@ ExceptionDog.configure do |config|
36
37
  config.notifier = Rails.env.test? ? "ExceptionDog::LogNotifier" : "ExceptionDog::HttpNotifier"
37
38
  config.logger = Rails.logger
38
39
  config.service_name = Rails.application.class.parent.name.underscore
40
+ config.ignore_exceptions = ["ActionController::RoutingError"]
39
41
  end
40
42
  ```
41
43
 
Binary file
data/lib/exception_dog.rb CHANGED
@@ -21,6 +21,7 @@ module ExceptionDog
21
21
  attr_accessor :agent_port
22
22
  attr_accessor :notifier
23
23
  attr_accessor :notifier_instance
24
+ attr_accessor :ignore_exceptions
24
25
 
25
26
  def initialize
26
27
  self.source_type_name = 'my_apps'
@@ -31,6 +32,7 @@ module ExceptionDog
31
32
  self.agent_port = 8125
32
33
  self.tags = []
33
34
  self.logger = Logger.new(STDOUT)
35
+ self.ignore_exceptions = []
34
36
  end
35
37
 
36
38
  def errors
@@ -15,6 +15,7 @@ module ExceptionDog
15
15
 
16
16
 
17
17
  def notify(exception, data)
18
+ return if ignored(exception)
18
19
  attach_dd_trace_id(data) if self.class.dd_trace_enabled
19
20
  title = exception.message[0..MAX_TITLE_LENGTH]
20
21
  text = exception_text(exception, data)[0..MAX_TEXT_LEGNTH]
@@ -32,7 +33,7 @@ module ExceptionDog
32
33
  data.each do |key, val|
33
34
  detail << "#{key}: #{val && val.to_s[0..MAX_LINE_LENGTH]}"
34
35
  end
35
- (detail + (exception.backtrace || []))[0..BACKTRACE_LINES].compact.join("\n")
36
+ (detail + format_backtrace(exception.backtrace)).compact.join("\n")
36
37
  end
37
38
 
38
39
  def aggregation_key(exception)
@@ -40,7 +41,19 @@ module ExceptionDog
40
41
  end
41
42
 
42
43
  def attach_dd_trace_id(data)
43
- data[:trace_id] = self.class.current_trace_id
44
+ data[:trace_id] = "[Trace](https://app.datadoghq.com/apm/trace/#{self.class.current_trace_id})" if self.class.current_trace_id
45
+ end
46
+
47
+ def ignored(exception)
48
+ configuration.ignore_exceptions&.include?(exception.class.name)
49
+ end
50
+
51
+ # remove backticks, single quotes, \n and ensure each line is reasonably small
52
+ def format_backtrace(backtrace)
53
+ backtrace ||= []
54
+ backtrace[0..BACKTRACE_LINES].collect do |line|
55
+ "`#{line.gsub(/\n|\`|\'/, '')}`\n"[0..MAX_LINE_LENGTH]
56
+ end
44
57
  end
45
58
 
46
59
  def self.current_trace_id
@@ -23,6 +23,10 @@ module ExceptionDog
23
23
  @@last_log
24
24
  end
25
25
 
26
+ def self.clear_log
27
+ @@last_log = nil
28
+ end
29
+
26
30
  def errors
27
31
  []
28
32
  end
@@ -1,3 +1,3 @@
1
1
  module ExceptionDog
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_dog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Baguley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-09 00:00:00.000000000 Z
11
+ date: 2018-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogstatsd-ruby
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile
97
97
  - bin/console
98
98
  - bin/setup
99
+ - exception_dog-0.3.2.gem
99
100
  - exception_dog.gemspec
100
101
  - lib/exception_dog.rb
101
102
  - lib/exception_dog/agent_notifier.rb