honeybadger 2.0.0.beta.2 → 2.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff1cb69549509f0a3ba7d723dcbed181b4f8845d
4
- data.tar.gz: d413ed284a9b6fb3a8be8ae3c8621514cb4f4037
3
+ metadata.gz: 2a59b10cd827731513426b228e5d19a58af562ca
4
+ data.tar.gz: c9691c718cfac669916547060fe2515437ef09a6
5
5
  SHA512:
6
- metadata.gz: eba0eaf3bd4cc030b43904b0f855fbb536893faddbd095a046a4edeab8a2bfa876963e42e14dd9adcbbba00341230b11a20d2e7138128053790edc3c2133ed6c
7
- data.tar.gz: 728b30a14a67a0f91ded6f26010fae33f8671780c3aab6ac4b57c38e16699f73f49b23bc902a308377e47a6a8866378b8f50dcbc367de9d39868c2bf2606e792
6
+ metadata.gz: baaa7ad6cd490e13aa917cd02c684b3c04850b81f4943c8612aabd961b321f990ade9bcc5cb9f3f879cfd7d4b6683b7d2d4798c5f0a1a43544fb3b1a2b5df89f
7
+ data.tar.gz: d91ee78cc723be8421b9c1adef00e59142558f2123f655862d070abb09f0e03aa66811094aa563d7e1b72d749ee8d27efc09c26b8cfd719012dbeb9c49020b4c
@@ -229,8 +229,8 @@ module Honeybadger
229
229
  say(tab_indent(hierarchy.size) << "#{key}:")
230
230
  indent = tab_indent(hierarchy.size+1)
231
231
  say(indent + "Description: #{Config::OPTIONS[dotted_key][:description]}")
232
- say(indent + "Default: #{Config::OPTIONS[dotted_key][:default].to_s}")
233
- say(indent + "Current: #{value.to_s}")
232
+ say(indent + "Default: #{Config::OPTIONS[dotted_key][:default].inspect}")
233
+ say(indent + "Current: #{value.inspect}")
234
234
  end
235
235
  end
236
236
  end
@@ -178,6 +178,15 @@ module Honeybadger
178
178
  request && request.env['action_dispatch.parameter_filter'] or []
179
179
  end
180
180
 
181
+ def excluded_request_keys
182
+ [].tap do |keys|
183
+ keys << :session if self[:'request.disable_session']
184
+ keys << :params if self[:'request.disable_params']
185
+ keys << :cgi_data if self[:'request.disable_environment']
186
+ keys << :url if self[:'request.disable_url']
187
+ end
188
+ end
189
+
181
190
  def write
182
191
  path = config_path
183
192
 
@@ -5,9 +5,10 @@ module Honeybadger
5
5
  IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
6
6
  'ActionController::RoutingError',
7
7
  'ActionController::InvalidAuthenticityToken',
8
- 'CGI::Session::CookieStore::TamperedWithCookie',
9
8
  'ActionController::UnknownAction',
9
+ 'ActionController::UnknownFormat',
10
10
  'AbstractController::ActionNotFound',
11
+ 'CGI::Session::CookieStore::TamperedWithCookie',
11
12
  'Mongoid::Errors::DocumentNotFound',
12
13
  'Sinatra::NotFound'].map(&:freeze).freeze
13
14
 
@@ -112,9 +113,21 @@ module Honeybadger
112
113
  description: 'A list of keys to filter when sending request data.',
113
114
  default: ['password'.freeze, 'password_confirmation'.freeze].freeze
114
115
  },
115
- :'request.exclude_keys' => {
116
- description: 'A list of top-level keys to exclude when sending request data.',
117
- default: [].freeze
116
+ :'request.disable_session' => {
117
+ description: 'Prevent session from being sent with request data.',
118
+ default: false
119
+ },
120
+ :'request.disable_params' => {
121
+ description: 'Prevent params from being sent with request data.',
122
+ default: false
123
+ },
124
+ :'request.disable_environment' => {
125
+ description: 'Prevent Rack environment from being sent with request data.',
126
+ default: false
127
+ },
128
+ :'request.disable_url' => {
129
+ description: 'Prevent url from being sent with request data (Rack environment may still contain it in some cases).',
130
+ default: false
118
131
  },
119
132
  :'user_informer.enabled' => {
120
133
  description: 'Enable the UserInformer middleware.',
@@ -1,11 +1,12 @@
1
1
  require 'pathname'
2
2
  require 'yaml'
3
+ require 'erb'
3
4
 
4
5
  module Honeybadger
5
6
  class Config
6
7
  class Yaml < ::Hash
7
8
  def initialize(path, env = 'production')
8
- @path = Pathname.new(path)
9
+ @path = path.kind_of?(Pathname) ? path : Pathname.new(path)
9
10
 
10
11
  if !@path.exist?
11
12
  raise ConfigError, "The configuration file #{@path} was not found."
@@ -14,9 +15,9 @@ module Honeybadger
14
15
  elsif !@path.writable?
15
16
  raise ConfigError, "The configuration file #{@path} is not writable."
16
17
  else
17
- yaml = YAML.load(@path.read)
18
- override = yaml.delete(env)
19
- update(dotify_keys(yaml.merge(override || {})))
18
+ yaml = YAML.load(ERB.new(@path.read).result)
19
+ yaml.merge!(yaml[env]) if yaml[env].kind_of?(Hash)
20
+ update(dotify_keys(yaml))
20
21
  end
21
22
 
22
23
  rescue StandardError => e
@@ -30,6 +30,16 @@ module Honeybadger
30
30
  # Internal: Matches lines beginning with ./
31
31
  RELATIVE_ROOT = Regexp.new('^\.\/').freeze
32
32
 
33
+ # Internal: default values to use for request data.
34
+ REQUEST_DEFAULTS = {
35
+ url: nil,
36
+ component: nil,
37
+ action: nil,
38
+ params: {}.freeze,
39
+ session: {}.freeze,
40
+ cgi_data: {}.freeze
41
+ }.freeze
42
+
33
43
  class Notice
34
44
  extend Forwardable
35
45
 
@@ -130,7 +140,7 @@ module Honeybadger
130
140
 
131
141
  @sanitizer = Util::Sanitizer.new(filters: config.params_filters)
132
142
  @request_sanitizer = Util::RequestSanitizer.new(@sanitizer)
133
- @request = OpenStruct.new(construct_request_hash(config.request, opts, @request_sanitizer))
143
+ @request = OpenStruct.new(construct_request_hash(config.request, opts, @request_sanitizer, config.excluded_request_keys))
134
144
  @context = construct_context_hash(opts, @sanitizer)
135
145
 
136
146
  @stats = Util::Stats.all
@@ -299,21 +309,16 @@ module Honeybadger
299
309
  ].compact | BACKTRACE_FILTERS
300
310
  end
301
311
 
302
- def construct_request_hash(rack_request, opts, sanitizer)
303
- defaults = {
304
- url: opts[:url],
305
- component: opts[:component] || opts[:controller],
306
- action: opts[:action],
307
- params: opts[:params] || opts[:parameters] || {},
308
- session: opts[:session] || {},
309
- cgi_data: opts[:cgi_data] || {}
310
- }
311
-
312
+ def construct_request_hash(rack_request, opts, sanitizer, excluded_keys = [])
312
313
  request = {}
313
314
  request.merge!(Rack::RequestHash.new(rack_request)) if rack_request
314
315
 
315
- defaults.each_pair do |k,v|
316
- request[k] = v if opts.has_key?(k) || !request.has_key?(k)
316
+ request[:component] = opts[:controller] if opts.has_key?(:controller)
317
+ request[:params] = opts[:parameters] if opts.has_key?(:parameters)
318
+
319
+ REQUEST_DEFAULTS.each do |key, default|
320
+ request[key] = opts[key] if opts.has_key?(key)
321
+ request[key] = default if !request[key] || excluded_keys.include?(key)
317
322
  end
318
323
 
319
324
  request[:session] = request[:session][:data] if request[:session][:data]
@@ -71,7 +71,7 @@ module Honeybadger
71
71
  def ok?(config)
72
72
  @requirements.all? {|r| Execution.new(config, &r).call }
73
73
  rescue => e
74
- config.logger.error(sprintf('plugin error name=%s class=%s message=%s location=%s', name, e.class, e.message.dump, e.backtrace.first.dump))
74
+ config.logger.error(sprintf('plugin error name=%s class=%s message=%s at=%s', name, e.class, e.message.dump, e.backtrace.first.dump))
75
75
  false
76
76
  end
77
77
 
@@ -89,7 +89,7 @@ module Honeybadger
89
89
 
90
90
  @loaded
91
91
  rescue => e
92
- config.logger.error(sprintf('plugin error name=%s class=%s message=%s location=%s', name, e.class, e.message.dump, e.backtrace.first.dump))
92
+ config.logger.error(sprintf('plugin error name=%s class=%s message=%s at=%s', name, e.class, e.message.dump, e.backtrace.first.dump))
93
93
  @loaded = true
94
94
  false
95
95
  end
@@ -66,7 +66,7 @@ module Honeybadger
66
66
  http
67
67
  rescue => e
68
68
  error do
69
- sprintf('http error class=%s message=%s location=%s', e.class, e.message.dump, e.backtrace.first.dump)
69
+ sprintf('http error class=%s message=%s at=%s', e.class, e.message.dump, e.backtrace.first.dump)
70
70
  end
71
71
  raise e
72
72
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # Public: The current String Honeybadger version.
3
- VERSION = '2.0.0.beta.2'.freeze
3
+ VERSION = '2.0.0.beta.3'.freeze
4
4
  end
@@ -70,15 +70,26 @@ module Honeybadger
70
70
  def trace(trace)
71
71
  if trace.duration > config[:'traces.threshold']
72
72
  debug { sprintf('worker adding trace duration=%s feature=traces id=%s', trace.duration.round(2), trace.id) }
73
- mutex.synchronize do
74
- traces.push(trace)
75
- end
73
+ traces.push(trace)
74
+ flush_traces if traces.flush?
75
+ true
76
76
  else
77
77
  debug { sprintf('worker discarding trace duration=%s feature=traces id=%s', trace.duration.round(2), trace.id) }
78
+ false
78
79
  end
79
80
  end
80
81
 
81
- def_delegators :@metrics, :timing, :increment
82
+ def timing(*args, &block)
83
+ metrics.timing(*args, &block)
84
+ flush_metrics if metrics.flush?
85
+ true
86
+ end
87
+
88
+ def increment(*args, &block)
89
+ metrics.increment(*args, &block)
90
+ flush_metrics if metrics.flush?
91
+ true
92
+ end
82
93
 
83
94
  private
84
95
 
@@ -108,14 +119,18 @@ module Honeybadger
108
119
 
109
120
  def flush_metrics
110
121
  debug { 'worker flushing metrics feature=metrics' } # TODO: Include count.
111
- metrics.chunk(100, &method(:push).to_proc.curry[:metrics])
112
- mutex.synchronize { init_metrics }
122
+ mutex.synchronize do
123
+ metrics.chunk(100, &method(:push).to_proc.curry[:metrics])
124
+ init_metrics
125
+ end
113
126
  end
114
127
 
115
128
  def flush_traces
116
129
  debug { sprintf('worker flushing traces feature=traces count=%d', traces.size) }
117
- push(:traces, traces) unless traces.empty?
118
- mutex.synchronize { init_traces }
130
+ mutex.synchronize do
131
+ push(:traces, traces) unless traces.empty?
132
+ init_traces
133
+ end
119
134
  end
120
135
 
121
136
  def flush_queue
@@ -145,9 +160,7 @@ module Honeybadger
145
160
  return false
146
161
  end
147
162
 
148
- mutex.synchronize do
149
- queue[feature].push(object)
150
- end
163
+ queue[feature].push(object)
151
164
 
152
165
  true
153
166
  end
@@ -157,7 +170,7 @@ module Honeybadger
157
170
  debug { 'worker started' }
158
171
  work until finish
159
172
  rescue Exception => e
160
- error(sprintf('error in worker thread (shutting down) class=%s message=%s location=%s', e.class, e.message.dump, e.backtrace.first.dump))
173
+ error(sprintf('error in worker thread (shutting down) class=%s message=%s at=%s', e.class, e.message.dump, e.backtrace.first.dump))
161
174
  raise e
162
175
  ensure
163
176
  debug { 'stopping worker' }
@@ -176,7 +189,7 @@ module Honeybadger
176
189
 
177
190
  sleep(0.1)
178
191
  rescue StandardError => e
179
- error(sprintf('error in worker thread class=%s message=%s location=%s', e.class, e.message.dump, e.backtrace.first.dump))
192
+ error(sprintf('error in worker thread class=%s message=%s at=%s', e.class, e.message.dump, e.backtrace.first.dump))
180
193
  sleep(1)
181
194
  end
182
195
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta.2
4
+ version: 2.0.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-10 00:00:00.000000000 Z
11
+ date: 2014-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email: