honeybadger 1.16.7 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +19 -0
- data/README.md +37 -16
- data/bin/honeybadger +5 -0
- data/lib/honeybadger.rb +167 -191
- data/lib/honeybadger/agent.rb +136 -0
- data/lib/honeybadger/backend.rb +26 -0
- data/lib/honeybadger/backend/base.rb +66 -0
- data/lib/honeybadger/backend/debug.rb +12 -0
- data/lib/honeybadger/backend/null.rb +16 -0
- data/lib/honeybadger/backend/server.rb +51 -0
- data/lib/honeybadger/backend/test.rb +24 -0
- data/lib/honeybadger/backtrace.rb +29 -24
- data/lib/honeybadger/cli.rb +367 -0
- data/lib/honeybadger/config.rb +333 -0
- data/lib/honeybadger/config/callbacks.rb +70 -0
- data/lib/honeybadger/config/defaults.rb +175 -0
- data/lib/honeybadger/config/env.rb +40 -0
- data/lib/honeybadger/config/yaml.rb +43 -0
- data/lib/honeybadger/const.rb +28 -0
- data/lib/honeybadger/init/rails.rb +84 -0
- data/lib/honeybadger/init/sinatra.rb +27 -0
- data/lib/honeybadger/logging.rb +133 -0
- data/lib/honeybadger/notice.rb +243 -280
- data/lib/honeybadger/plugin.rb +110 -0
- data/lib/honeybadger/plugins/delayed_job.rb +22 -0
- data/lib/honeybadger/{integrations → plugins}/delayed_job/plugin.rb +6 -7
- data/lib/honeybadger/{integrations → plugins}/local_variables.rb +7 -8
- data/lib/honeybadger/{integrations → plugins}/net_http.rb +10 -8
- data/lib/honeybadger/plugins/passenger.rb +24 -0
- data/lib/honeybadger/plugins/rails.rb +61 -0
- data/lib/honeybadger/plugins/sidekiq.rb +35 -0
- data/lib/honeybadger/{integrations → plugins}/thor.rb +9 -8
- data/lib/honeybadger/{integrations → plugins}/unicorn.rb +10 -9
- data/lib/honeybadger/rack/error_notifier.rb +44 -27
- data/lib/honeybadger/rack/metrics_reporter.rb +41 -0
- data/lib/honeybadger/rack/request_hash.rb +50 -0
- data/lib/honeybadger/rack/user_feedback.rb +15 -10
- data/lib/honeybadger/rack/user_informer.rb +14 -3
- data/lib/honeybadger/trace.rb +185 -0
- data/lib/honeybadger/util/http.rb +79 -0
- data/lib/honeybadger/util/request_sanitizer.rb +35 -0
- data/lib/honeybadger/util/sanitizer.rb +71 -0
- data/lib/honeybadger/util/stats.rb +31 -0
- data/lib/honeybadger/version.rb +4 -0
- data/lib/honeybadger/worker.rb +224 -0
- data/lib/honeybadger/worker/batch.rb +50 -0
- data/lib/honeybadger/worker/metered_queue.rb +80 -0
- data/lib/honeybadger/worker/metrics_collection.rb +61 -0
- data/lib/honeybadger/worker/metrics_collector.rb +96 -0
- data/{lib/honeybadger/capistrano.rb → vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb} +1 -3
- data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +76 -0
- data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -0
- data/{lib → vendor/capistrano-honeybadger/lib}/honeybadger/capistrano/legacy.rb +16 -15
- data/vendor/thor/lib/thor.rb +484 -0
- data/vendor/thor/lib/thor/actions.rb +319 -0
- data/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/vendor/thor/lib/thor/base.rb +656 -0
- data/vendor/thor/lib/thor/command.rb +133 -0
- data/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/vendor/thor/lib/thor/error.rb +32 -0
- data/vendor/thor/lib/thor/group.rb +281 -0
- data/vendor/thor/lib/thor/invocation.rb +178 -0
- data/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/vendor/thor/lib/thor/parser.rb +4 -0
- data/vendor/thor/lib/thor/parser/argument.rb +73 -0
- data/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/vendor/thor/lib/thor/runner.rb +322 -0
- data/vendor/thor/lib/thor/shell.rb +81 -0
- data/vendor/thor/lib/thor/shell/basic.rb +421 -0
- data/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/vendor/thor/lib/thor/util.rb +267 -0
- data/vendor/thor/lib/thor/version.rb +3 -0
- metadata +97 -305
- data/Appraisals +0 -95
- data/CHANGELOG.md +0 -422
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -136
- data/Guardfile +0 -5
- data/MIT-LICENSE +0 -32
- data/Rakefile +0 -159
- data/features/metal.feature +0 -20
- data/features/rack.feature +0 -55
- data/features/rails.feature +0 -343
- data/features/rails3.x.feature +0 -26
- data/features/rake.feature +0 -25
- data/features/sinatra.feature +0 -27
- data/features/standalone.feature +0 -73
- data/features/step_definitions/metal_steps.rb +0 -24
- data/features/step_definitions/rack_steps.rb +0 -18
- data/features/step_definitions/rails_steps.rb +0 -270
- data/features/step_definitions/rake_steps.rb +0 -17
- data/features/step_definitions/standalone_steps.rb +0 -12
- data/features/step_definitions/thor_steps.rb +0 -4
- data/features/support/env.rb +0 -22
- data/features/support/honeybadger_failure_shim.rb.template +0 -5
- data/features/support/honeybadger_shim.rb.template +0 -6
- data/features/support/rails.rb +0 -202
- data/features/support/rake/Rakefile +0 -68
- data/features/support/test.thor +0 -22
- data/features/thor.feature +0 -5
- data/gemfiles/binding_of_caller.gemfile +0 -13
- data/gemfiles/delayed_job.gemfile +0 -13
- data/gemfiles/rack.gemfile +0 -13
- data/gemfiles/rails.gemfile +0 -16
- data/gemfiles/rails2.3.gemfile +0 -15
- data/gemfiles/rails3.0.gemfile +0 -16
- data/gemfiles/rails3.1.gemfile +0 -16
- data/gemfiles/rails3.2.gemfile +0 -16
- data/gemfiles/rails4.0.gemfile +0 -16
- data/gemfiles/rails4.1.gemfile +0 -16
- data/gemfiles/rake.gemfile +0 -13
- data/gemfiles/sinatra.gemfile +0 -13
- data/gemfiles/standalone.gemfile +0 -12
- data/gemfiles/thor.gemfile +0 -13
- data/generators/honeybadger/honeybadger_generator.rb +0 -95
- data/generators/honeybadger/lib/insert_commands.rb +0 -34
- data/generators/honeybadger/lib/rake_commands.rb +0 -24
- data/generators/honeybadger/templates/capistrano_hook.rb +0 -6
- data/generators/honeybadger/templates/honeybadger_tasks.rake +0 -25
- data/generators/honeybadger/templates/initializer.rb +0 -6
- data/honeybadger.gemspec +0 -174
- data/lib/honeybadger/array.rb +0 -53
- data/lib/honeybadger/capistrano/tasks.rake +0 -73
- data/lib/honeybadger/configuration.rb +0 -397
- data/lib/honeybadger/dependency.rb +0 -65
- data/lib/honeybadger/integrations.rb +0 -9
- data/lib/honeybadger/integrations/delayed_job.rb +0 -20
- data/lib/honeybadger/integrations/passenger.rb +0 -18
- data/lib/honeybadger/integrations/sidekiq.rb +0 -37
- data/lib/honeybadger/monitor.rb +0 -17
- data/lib/honeybadger/monitor/railtie.rb +0 -53
- data/lib/honeybadger/monitor/sender.rb +0 -44
- data/lib/honeybadger/monitor/trace.rb +0 -187
- data/lib/honeybadger/monitor/worker.rb +0 -169
- data/lib/honeybadger/payload.rb +0 -101
- data/lib/honeybadger/rack.rb +0 -12
- data/lib/honeybadger/rails.rb +0 -45
- data/lib/honeybadger/rails/action_controller_catcher.rb +0 -30
- data/lib/honeybadger/rails/controller_methods.rb +0 -78
- data/lib/honeybadger/rails/middleware/exceptions_catcher.rb +0 -29
- data/lib/honeybadger/rails3_tasks.rb +0 -94
- data/lib/honeybadger/railtie.rb +0 -52
- data/lib/honeybadger/rake_handler.rb +0 -66
- data/lib/honeybadger/sender.rb +0 -185
- data/lib/honeybadger/shared_tasks.rb +0 -56
- data/lib/honeybadger/stats.rb +0 -29
- data/lib/honeybadger/tasks.rb +0 -95
- data/lib/honeybadger/user_feedback.rb +0 -8
- data/lib/honeybadger/user_informer.rb +0 -8
- data/lib/honeybadger_tasks.rb +0 -69
- data/lib/rails/generators/honeybadger/honeybadger_generator.rb +0 -99
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/script/integration_test.rb +0 -38
- data/spec/allocation_stats.rb +0 -32
- data/spec/honeybadger/backtrace_spec.rb +0 -242
- data/spec/honeybadger/capistrano_spec.rb +0 -36
- data/spec/honeybadger/configuration_spec.rb +0 -328
- data/spec/honeybadger/dependency_spec.rb +0 -134
- data/spec/honeybadger/integrations/delayed_job_spec.rb +0 -82
- data/spec/honeybadger/integrations/local_variables_spec.rb +0 -60
- data/spec/honeybadger/integrations/net_http_spec.rb +0 -29
- data/spec/honeybadger/integrations/passenger_spec.rb +0 -29
- data/spec/honeybadger/integrations/sidekiq_spec.rb +0 -60
- data/spec/honeybadger/integrations/thor_spec.rb +0 -32
- data/spec/honeybadger/integrations/unicorn_spec.rb +0 -40
- data/spec/honeybadger/logger_spec.rb +0 -79
- data/spec/honeybadger/monitor/trace_spec.rb +0 -65
- data/spec/honeybadger/monitor/worker_spec.rb +0 -274
- data/spec/honeybadger/notice_spec.rb +0 -669
- data/spec/honeybadger/notifier_spec.rb +0 -328
- data/spec/honeybadger/payload_spec.rb +0 -162
- data/spec/honeybadger/rack_spec.rb +0 -85
- data/spec/honeybadger/rails/action_controller_spec.rb +0 -328
- data/spec/honeybadger/rails_spec.rb +0 -37
- data/spec/honeybadger/sender_spec.rb +0 -317
- data/spec/honeybadger/stats_spec.rb +0 -57
- data/spec/honeybadger/user_feedback_spec.rb +0 -80
- data/spec/honeybadger/user_informer_spec.rb +0 -30
- data/spec/honeybadger_tasks_spec.rb +0 -171
- data/spec/spec_helper.rb +0 -24
- data/spec/support/array_including.rb +0 -31
- data/spec/support/backtraced_exception.rb +0 -9
- data/spec/support/collected_sender.rb +0 -12
- data/spec/support/defines_constants.rb +0 -18
- data/spec/support/helpers.rb +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7da3276ec8bbc96881dc0edf11dfa62dfb0081dc
|
4
|
+
data.tar.gz: dd2d483879772690a1049a6de31bcaf37058d09a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afa97bb207635301b1106641a54408b1024858449a275b31ea7eec3fc4c404f69b4d65b3cffac35a70ab04866fa4f7fe36e277f8233fc6bba3743c90473cafdc
|
7
|
+
data.tar.gz: 0b46525e824d08b42af3415a0c687eeed306a788a229c6dcd069e72432716512093b8a70d0e4fba5044cdf1e85d521f5c6d98b8da732daa8abbd071816c76f31
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Honeybadger Industries LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,29 +1,52 @@
|
|
1
|
-
# Honeybadger
|
1
|
+
# Honeybadger for Ruby
|
2
2
|
|
3
|
+
[![Code Climate](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby/badges/gpa.svg)](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby)
|
3
4
|
[![Build Status](https://secure.travis-ci.org/honeybadger-io/honeybadger-ruby.png?branch=master)](http://travis-ci.org/honeybadger-io/honeybadger-ruby)
|
4
5
|
[![Gem Version](https://badge.fury.io/rb/honeybadger.png)](http://badge.fury.io/rb/honeybadger)
|
5
6
|
|
6
7
|
This is the notifier gem for integrating apps with the :zap: [Honeybadger Exception Notifier for Ruby and Rails](http://honeybadger.io).
|
7
8
|
|
8
|
-
When an uncaught exception occurs, Honeybadger will POST the relevant data
|
9
|
-
to the Honeybadger server specified in your environment.
|
9
|
+
When an uncaught exception occurs, Honeybadger will POST the relevant data to the Honeybadger server specified in your environment.
|
10
10
|
|
11
11
|
## Supported Ruby versions
|
12
12
|
|
13
|
-
|
13
|
+
Honeybadger officially supports the following Ruby versions and implementations:
|
14
14
|
|
15
|
-
|
15
|
+
| Ruby | Version |
|
16
|
+
| ------------- | ------------------|
|
17
|
+
| MRI | >= 1.9.3 |
|
18
|
+
| JRuby | >= 1.7 (1.9 mode) |
|
19
|
+
| Rubinius | >= 2.0 |
|
16
20
|
|
17
|
-
## Supported
|
21
|
+
## Supported frameworks
|
18
22
|
|
19
|
-
|
23
|
+
The following frameworks are supported:
|
24
|
+
|
25
|
+
| Framework | Version | Native? |
|
26
|
+
| ------------- | ------------- |------------|
|
27
|
+
| Rails | >= 3.0 | yes |
|
28
|
+
| Sinatra | >= 1.2.1 | yes |
|
29
|
+
| Rack | >= 1.0 | middleware |
|
30
|
+
|
31
|
+
Rails and Sinatra are supported natively (install/configure the gem and you're done). For vanilla Rack apps, we provide a collection of middleware that must be installed manually.
|
32
|
+
|
33
|
+
Integrating with other libraries/frameworks is simple! [See the documentation](http://rubydoc.info/gems/honeybadger/) to learn about our public API, and see [Contributing](#contributing) to suggest a patch.
|
20
34
|
|
21
35
|
## Documentation
|
22
36
|
|
23
|
-
[
|
37
|
+
* [Basic usage](http://rubydoc.info/gems/honeybadger/)
|
38
|
+
* [Full documentation](http://docs.honeybadger.io/article/50-honeybadger-gem-documentation)
|
39
|
+
|
40
|
+
## Changelog
|
41
|
+
|
42
|
+
See https://github.com/honeybadger-io/honeybadger-ruby/releases
|
24
43
|
|
25
44
|
## Contributing
|
26
45
|
|
46
|
+
If you're adding a new feature, please [submit an issue](https://github.com/honeybadger-io/honeybadger-ruby/issues/new) as a preliminary step; that way you can be (moderately) sure that your pull request will be accepted.
|
47
|
+
|
48
|
+
### To contribute your code:
|
49
|
+
|
27
50
|
1. Fork it.
|
28
51
|
2. Create a topic branch `git checkout -b my_branch`
|
29
52
|
3. Commit your changes `git commit -am "Boom"`
|
@@ -32,15 +55,13 @@ Honeybadger supports Rails 2.3 through Rails 4.2 (latest releases).
|
|
32
55
|
|
33
56
|
### Running the tests
|
34
57
|
|
35
|
-
We're using the
|
36
|
-
[
|
37
|
-
|
38
|
-
use `rake appraisal cucumber`. Type `rake -T` for a complete list of
|
39
|
-
available tasks.
|
58
|
+
We're using the [Appraisal](https://github.com/thoughtbot/appraisal) gem to run
|
59
|
+
our [RSpec](https://www.relishapp.com/rspec/) test suite against multiple
|
60
|
+
versions of [Rails](http://rubyonrails.org/).
|
40
61
|
|
41
|
-
The
|
42
|
-
|
62
|
+
* The unit test suite can be run with `rake` (aliased to `rake spec:unit`).
|
63
|
+
* The integration test suite can be run with `rake spec:features`.
|
43
64
|
|
44
65
|
### License
|
45
66
|
|
46
|
-
The Honeybadger gem is MIT licensed. See the [
|
67
|
+
The Honeybadger gem is MIT licensed. See the [LICENSE](https://raw.github.com/honeybadger-io/honeybadger-ruby/master/LICENSE) file in this repository for details.
|
data/bin/honeybadger
ADDED
data/lib/honeybadger.rb
CHANGED
@@ -1,204 +1,180 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'json'
|
4
|
-
require 'digest'
|
5
|
-
require 'logger'
|
6
|
-
|
7
|
-
require 'honeybadger/dependency'
|
8
|
-
require 'honeybadger/configuration'
|
9
|
-
require 'honeybadger/backtrace'
|
10
|
-
require 'honeybadger/notice'
|
11
|
-
require 'honeybadger/rack'
|
12
|
-
require 'honeybadger/sender'
|
13
|
-
require 'honeybadger/stats'
|
14
|
-
require 'honeybadger/user_informer'
|
15
|
-
require 'honeybadger/user_feedback'
|
16
|
-
require 'honeybadger/integrations'
|
17
|
-
|
18
|
-
require 'honeybadger/railtie' if defined?(Rails::Railtie)
|
19
|
-
require 'honeybadger/monitor'
|
1
|
+
require 'forwardable'
|
2
|
+
require 'honeybadger/const'
|
20
3
|
|
21
4
|
module Honeybadger
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
# Prints out the response body from Honeybadger for debugging help
|
52
|
-
def report_response_body(response)
|
53
|
-
write_verbose_log("Response from Honeybadger: \n#{response}")
|
54
|
-
end
|
55
|
-
|
56
|
-
# Returns the Ruby version, Rails version, and current Rails environment
|
57
|
-
def environment_info
|
58
|
-
info = "[Ruby: #{RUBY_VERSION}]"
|
59
|
-
info << " [#{configuration.framework}]" if configuration.framework
|
60
|
-
info << " [Env: #{configuration.environment_name}]" if configuration.environment_name
|
61
|
-
end
|
62
|
-
|
63
|
-
# Writes out the given message to the #logger
|
64
|
-
def write_verbose_log(message, level = Honeybadger.configuration.debug ? :info : :debug)
|
65
|
-
logger.send(level, LOG_PREFIX + message) if logger
|
66
|
-
end
|
67
|
-
|
68
|
-
# Look for the Rails logger currently defined
|
69
|
-
def logger
|
70
|
-
self.configuration.logger
|
71
|
-
end
|
72
|
-
|
73
|
-
# Public: Call this method to modify defaults in your initializers.
|
74
|
-
#
|
75
|
-
# Examples:
|
76
|
-
#
|
77
|
-
# Honeybadger.configure do |config|
|
78
|
-
# config.api_key = '1234567890abcdef'
|
79
|
-
# config.secure = false
|
80
|
-
# end
|
81
|
-
#
|
82
|
-
# Yields Honeybadger configuration
|
83
|
-
def configure(silent = false)
|
84
|
-
yield(configuration)
|
85
|
-
self.sender = Sender.new(configuration)
|
86
|
-
report_ready unless silent
|
87
|
-
self.sender
|
88
|
-
end
|
89
|
-
|
90
|
-
# Public: The configuration object.
|
91
|
-
# See Honeybadger.configure
|
92
|
-
#
|
93
|
-
# Returns Honeybadger configuration
|
94
|
-
def configuration
|
95
|
-
@configuration ||= Configuration.new
|
96
|
-
end
|
97
|
-
|
98
|
-
# Internal: Contacts the Honeybadger service and configures features
|
99
|
-
#
|
100
|
-
# configuration - the Configuration object to use
|
101
|
-
#
|
102
|
-
# Returns Hash features on success, NilClass on failure
|
103
|
-
def ping(configuration)
|
104
|
-
if configuration.public?
|
105
|
-
if result = sender.ping({ :version => Honeybadger::VERSION, :framework => configuration.framework, :environment => configuration.environment_name, :hostname => configuration.hostname })
|
106
|
-
if features = result['features']
|
107
|
-
configuration.features = features
|
108
|
-
configuration.metrics = false unless features['metrics']
|
109
|
-
configuration.traces = false unless features['traces']
|
110
|
-
features
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Public: Sends an exception manually using this method, even when you are not in a controller.
|
117
|
-
#
|
118
|
-
# exception - The exception you want to notify Honeybadger about.
|
119
|
-
# options - Data that will be sent to Honeybadger.
|
120
|
-
# :api_key - The API key for this project. The API key is a unique identifier
|
121
|
-
# that Honeybadger uses for identification.
|
122
|
-
# :error_message - The error returned by the exception (or the message you want to log).
|
123
|
-
# :backtrace - A backtrace, usually obtained with +caller+.
|
124
|
-
# :rack_env - The Rack environment.
|
125
|
-
# :session - The contents of the user's session.
|
126
|
-
# :environment_name - The application environment name.
|
127
|
-
# :context - Custom hash to send
|
128
|
-
#
|
129
|
-
# Returns exception ID from Honeybadger on success, false on failure
|
130
|
-
def notify(exception, options = {})
|
131
|
-
send_notice(build_notice_for(exception, options))
|
132
|
-
end
|
133
|
-
|
134
|
-
# Public: Sends the notice unless it is one of the default ignored exceptions
|
135
|
-
# see Honeybadger.notify
|
136
|
-
def notify_or_ignore(exception, opts = {})
|
137
|
-
notice = build_notice_for(exception, opts)
|
138
|
-
send_notice(notice) unless notice.ignore?
|
139
|
-
end
|
140
|
-
|
141
|
-
def build_lookup_hash_for(exception, options = {})
|
142
|
-
notice = build_notice_for(exception, options)
|
143
|
-
|
144
|
-
result = {}
|
145
|
-
result[:action] = notice.action rescue nil
|
146
|
-
result[:component] = notice.component rescue nil
|
147
|
-
result[:error_class] = notice.error_class if notice.error_class
|
148
|
-
result[:environment_name] = 'production'
|
149
|
-
|
150
|
-
unless notice.backtrace.lines.empty?
|
151
|
-
result[:file] = notice.backtrace.lines[0].file
|
152
|
-
result[:line_number] = notice.backtrace.lines[0].number
|
153
|
-
end
|
154
|
-
|
155
|
-
result
|
156
|
-
end
|
157
|
-
|
158
|
-
def context(hash = nil)
|
159
|
-
unless hash.nil?
|
160
|
-
Thread.current[:honeybadger_context] ||= {}
|
161
|
-
Thread.current[:honeybadger_context].merge!(hash)
|
162
|
-
end
|
5
|
+
include Forwardable
|
6
|
+
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# Public: Starts the Honeybadger service.
|
10
|
+
#
|
11
|
+
# opts - The Hash options used to initialize Honeybadger. Accepts config
|
12
|
+
# keys in addition to the listed options. Order of precedence for
|
13
|
+
# config is: 1) ENV, 2) config on disk, 3) opts. (default: {})
|
14
|
+
# :logger - An alternate Logger to use. (optional)
|
15
|
+
#
|
16
|
+
# Examples:
|
17
|
+
#
|
18
|
+
# ENV['HONEYBADGER_API_KEY'] # => 'asdf'
|
19
|
+
#
|
20
|
+
# Honeybadger.start # => true
|
21
|
+
#
|
22
|
+
# Honeybadger.start({
|
23
|
+
# :root => ::Rails.root,
|
24
|
+
# :'config.path' => 'config/',
|
25
|
+
# :logger => Honeybadger::Logging::FormattedLogger.new(::Rails.logger)
|
26
|
+
# }) # => true
|
27
|
+
#
|
28
|
+
# Returns true if started, otherwise false.
|
29
|
+
def start(config = {})
|
30
|
+
Agent.start(config)
|
31
|
+
end
|
163
32
|
|
164
|
-
|
165
|
-
|
33
|
+
# Public: Stops the Honeybadger service.
|
34
|
+
#
|
35
|
+
# Examples:
|
36
|
+
#
|
37
|
+
# Honeybadger.stop # => nil
|
38
|
+
#
|
39
|
+
# Returns nothing
|
40
|
+
def stop
|
41
|
+
Agent.stop
|
42
|
+
end
|
166
43
|
|
167
|
-
|
168
|
-
|
169
|
-
|
44
|
+
# Public: Send an exception to Honeybadger.
|
45
|
+
#
|
46
|
+
# exception_or_opts - An Exception object, or a Hash of options which is used
|
47
|
+
# to build the notice.
|
48
|
+
# opts - The options Hash when the first argument is an
|
49
|
+
# Exception. (default: {}):
|
50
|
+
# :error_class - The String class name of the error.
|
51
|
+
# :error_message - The String error message.
|
52
|
+
#
|
53
|
+
# Examples:
|
54
|
+
#
|
55
|
+
# # With an exception:
|
56
|
+
# begin
|
57
|
+
# fail 'oops'
|
58
|
+
# rescue => exception
|
59
|
+
# Honeybadger.notify(exception, context: {
|
60
|
+
# my_data: 'value'
|
61
|
+
# }) # => '0dfb92ae-9b01-42e9-9c13-31205b70744a'
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# # Custom notification:
|
65
|
+
# Honeybadger.notify({
|
66
|
+
# error_class: 'MyClass',
|
67
|
+
# error_message: 'Something went wrong.',
|
68
|
+
# context: {my_data: 'value'}
|
69
|
+
# }) # => '06221c5a-b471-41e5-baeb-de247da45a56'
|
70
|
+
#
|
71
|
+
# Returns a String UUID reference to the notice within Honeybadger.
|
72
|
+
def notify(exception_or_opts, opts = {})
|
73
|
+
opts.merge!(exception: exception_or_opts) if exception_or_opts.is_a?(Exception)
|
74
|
+
opts.merge!(exception_or_opts.to_hash) if exception_or_opts.respond_to?(:to_hash)
|
75
|
+
Agent.instance ? Agent.instance.notice(opts) : false
|
76
|
+
end
|
170
77
|
|
171
|
-
|
78
|
+
# Deprecated: Legacy support.
|
79
|
+
alias_method :notify_or_ignore, :notify
|
80
|
+
|
81
|
+
# Public: Callback to ignore exceptions.
|
82
|
+
#
|
83
|
+
# See public API documentation for Honeybadger::Notice for available attributes.
|
84
|
+
#
|
85
|
+
# block - A block returning TrueClass true (to ignore) or FalseClass false
|
86
|
+
# (to send).
|
87
|
+
#
|
88
|
+
# Examples:
|
89
|
+
#
|
90
|
+
# # Ignoring based on error message:
|
91
|
+
# Honeybadger.exception_filter do |notice|
|
92
|
+
# notice[:error_message] =~ /sensitive data/
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# # Ignore an entire class of exceptions:
|
96
|
+
# Honeybadger.exception_filter do |notice|
|
97
|
+
# notice[:exception].class < MyError
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# Returns nothing.
|
101
|
+
def exception_filter(&block)
|
102
|
+
Agent.exception_filter(&block)
|
103
|
+
end
|
172
104
|
|
173
|
-
|
174
|
-
|
105
|
+
# Public: Callback to add a custom grouping strategy for exceptions. The
|
106
|
+
# return value is hashed and sent to Honeybadger. Errors with the same
|
107
|
+
# fingerprint will be grouped.
|
108
|
+
#
|
109
|
+
# See public API documentation for Honeybadger::Notice for available attributes.
|
110
|
+
#
|
111
|
+
# block - A block returning any Object responding to #to_s.
|
112
|
+
#
|
113
|
+
# Examples:
|
114
|
+
#
|
115
|
+
# Honeybadger.exception_fingerprint do |notice|
|
116
|
+
# [notice[:error_class], notice[:component], notice[:backtrace].to_s].join(':')
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# Returns nothing.
|
120
|
+
def exception_fingerprint(&block)
|
121
|
+
Agent.exception_fingerprint(&block)
|
122
|
+
end
|
175
123
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
124
|
+
# Public: Callback to filter backtrace lines. One use for this is to make
|
125
|
+
# additional [PROJECT_ROOT] or [GEM_ROOT] substitutions, which are used by
|
126
|
+
# Honeybadger when grouping errors and displaying application traces.
|
127
|
+
#
|
128
|
+
# block - A block which can be used to modify the Backtrace lines sent to
|
129
|
+
# Honeybadger. The block expects one argument (line) which is the String line
|
130
|
+
# from the Backtrace, and must return the String new line.
|
131
|
+
#
|
132
|
+
# Examples:
|
133
|
+
#
|
134
|
+
# Honeybadger.backtrace_filter do |line|
|
135
|
+
# line.gsub(/^\/my\/unknown\/bundle\/path/, "[GEM_ROOT]")
|
136
|
+
# end
|
137
|
+
#
|
138
|
+
# Returns nothing.
|
139
|
+
def backtrace_filter(&block)
|
140
|
+
Agent.backtrace_filter(&block)
|
141
|
+
end
|
184
142
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
143
|
+
# Public: Save global context for the current request.
|
144
|
+
#
|
145
|
+
# hash - A Hash of data which will be sent to Honeybadger when an error
|
146
|
+
# occurs. (default: nil)
|
147
|
+
#
|
148
|
+
# Examples:
|
149
|
+
#
|
150
|
+
# Honeybadger.context({my_data: 'my value'})
|
151
|
+
#
|
152
|
+
# # Inside a Rails controller:
|
153
|
+
# before_action do
|
154
|
+
# Honeybadger.context({user_id: current_user.id})
|
155
|
+
# end
|
156
|
+
#
|
157
|
+
# # Clearing global context:
|
158
|
+
# Honeybadger.context.clear!
|
159
|
+
#
|
160
|
+
# Returns self so that method calls can be chained.
|
161
|
+
def context(hash = nil)
|
162
|
+
unless hash.nil?
|
163
|
+
Thread.current[:__honeybadger_context] ||= {}
|
164
|
+
Thread.current[:__honeybadger_context].merge!(hash)
|
165
|
+
end
|
166
|
+
|
167
|
+
self
|
168
|
+
end
|
191
169
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
exception.respond_to?(:continued_exception) && exception.continued_exception ||
|
196
|
-
exception.respond_to?(:cause) && exception.cause ||
|
197
|
-
exception
|
198
|
-
end
|
170
|
+
# Internal: Clears the global context
|
171
|
+
def clear!
|
172
|
+
Thread.current[:__honeybadger_context] = nil
|
199
173
|
end
|
200
174
|
end
|
201
175
|
|
202
|
-
|
203
|
-
|
176
|
+
if defined?(::Rails::Railtie)
|
177
|
+
require 'honeybadger/init/rails'
|
178
|
+
elsif defined?(Sinatra::Base)
|
179
|
+
require 'honeybadger/init/sinatra'
|
204
180
|
end
|