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
@@ -0,0 +1,70 @@
|
|
1
|
+
module Honeybadger
|
2
|
+
class Config
|
3
|
+
class Callbacks
|
4
|
+
attr_reader :backtrace_filter, :exception_filter, :exception_fingerprint
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@backtrace_filter = nil
|
8
|
+
@exception_filter = nil
|
9
|
+
@exception_fingerprint = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: Takes a block and adds it to the list of backtrace filters. When
|
13
|
+
# the filters run, the block will be handed each line of the backtrace and
|
14
|
+
# can modify it as necessary.
|
15
|
+
#
|
16
|
+
# &block - The new backtrace filter.
|
17
|
+
#
|
18
|
+
# Examples:
|
19
|
+
#
|
20
|
+
# config.backtrace_filter do |line|
|
21
|
+
# line.gsub(/^#{Rails.root}/, "[Rails.root]")
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# Yields a line in the backtrace.
|
25
|
+
def backtrace_filter(&block)
|
26
|
+
@backtrace_filter = Proc.new if block_given?
|
27
|
+
@backtrace_filter
|
28
|
+
end
|
29
|
+
|
30
|
+
# Public: Takes a block and adds it to the list of ignore filters. When
|
31
|
+
# the filters run, the block will be handed the exception.
|
32
|
+
#
|
33
|
+
# &block - The new ignore filter
|
34
|
+
# If the block returns true the exception will be ignored, otherwise it
|
35
|
+
# will be processed by honeybadger.
|
36
|
+
#
|
37
|
+
# Examples:
|
38
|
+
#
|
39
|
+
# config.exception_filter do |exception|
|
40
|
+
# if exception.class < MyError
|
41
|
+
# nil
|
42
|
+
# else
|
43
|
+
# exception
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# Yields the the exception data given to Honeybadger.notify
|
48
|
+
def exception_filter(&block)
|
49
|
+
@exception_filter = Proc.new if block_given?
|
50
|
+
@exception_filter
|
51
|
+
end
|
52
|
+
|
53
|
+
# Public: Generate custom fingerprint (optional)
|
54
|
+
#
|
55
|
+
# block - An optional block returning object responding to #to_s
|
56
|
+
#
|
57
|
+
# Examples
|
58
|
+
#
|
59
|
+
# config.exception_fingerprint do |notice|
|
60
|
+
# [notice[:error_class], notice[:component], notice[:backtrace].to_s].join(':')
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# Returns configured fingerprint generator (should respond to #call(notice))
|
64
|
+
def exception_fingerprint
|
65
|
+
@exception_fingerprint = Proc.new if block_given?
|
66
|
+
@exception_fingerprint
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
class Config
|
5
|
+
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
6
|
+
'ActionController::RoutingError',
|
7
|
+
'ActionController::InvalidAuthenticityToken',
|
8
|
+
'CGI::Session::CookieStore::TamperedWithCookie',
|
9
|
+
'ActionController::UnknownAction',
|
10
|
+
'AbstractController::ActionNotFound',
|
11
|
+
'Mongoid::Errors::DocumentNotFound',
|
12
|
+
'Sinatra::NotFound'].map(&:freeze).freeze
|
13
|
+
|
14
|
+
OPTIONS = {
|
15
|
+
enabled: {
|
16
|
+
description: 'Determines if Honeybadger will start.',
|
17
|
+
default: true
|
18
|
+
},
|
19
|
+
debug: {
|
20
|
+
description: 'Forces metrics and traces to be reported every 10 seconds rather than 60.',
|
21
|
+
default: false
|
22
|
+
},
|
23
|
+
api_key: {
|
24
|
+
description: 'The API key for your Honeybadger project.',
|
25
|
+
default: nil
|
26
|
+
},
|
27
|
+
hostname: {
|
28
|
+
description: 'The hostname of the current box.',
|
29
|
+
default: Socket.gethostname
|
30
|
+
},
|
31
|
+
root: {
|
32
|
+
description: 'The project\'s absolute root path.',
|
33
|
+
default: Dir.pwd
|
34
|
+
},
|
35
|
+
backend: {
|
36
|
+
description: 'An alternate backend to use for reporting data.',
|
37
|
+
default: nil
|
38
|
+
},
|
39
|
+
env: {
|
40
|
+
description: 'The current application\'s environment name.',
|
41
|
+
default: ENV['HONEYBADGER_ENV']
|
42
|
+
},
|
43
|
+
public: {
|
44
|
+
description: 'Enable reporting of data.',
|
45
|
+
default: nil
|
46
|
+
},
|
47
|
+
environments: {
|
48
|
+
description: 'Public environments which are enabled for reporting automatically.',
|
49
|
+
default: ['production'.freeze, 'staging'.freeze].freeze
|
50
|
+
},
|
51
|
+
plugins: {
|
52
|
+
description: 'An optional list of plugins to load. Default is to load all plugins.',
|
53
|
+
default: nil
|
54
|
+
},
|
55
|
+
:'plugins.skip' => {
|
56
|
+
description: 'An optional list of plugins to skip.',
|
57
|
+
default: nil
|
58
|
+
},
|
59
|
+
:'config.path' => {
|
60
|
+
description: 'The path (absolute, or relative from config.root) to the project\'s YAML configuration file.',
|
61
|
+
default: ENV['HONEYBADGER_CONFIG_PATH'] || ['honeybadger.yml', 'config/honeybadger.yml']
|
62
|
+
},
|
63
|
+
:'logging.path' => {
|
64
|
+
description: 'The path (absolute, or relative from config.root) to the log file.',
|
65
|
+
default: nil
|
66
|
+
},
|
67
|
+
:'logging.level' => {
|
68
|
+
description: 'The log level.',
|
69
|
+
default: 'INFO'
|
70
|
+
},
|
71
|
+
:'connection.secure' => {
|
72
|
+
description: 'Use SSL when sending data.',
|
73
|
+
default: true
|
74
|
+
},
|
75
|
+
:'connection.host' => {
|
76
|
+
description: 'The host to use when sending data.',
|
77
|
+
default: 'api.honeybadger.io'.freeze
|
78
|
+
},
|
79
|
+
:'connection.port' => {
|
80
|
+
description: 'The port to use when sending data.',
|
81
|
+
default: nil
|
82
|
+
},
|
83
|
+
:'connection.system_ssl_cert_chain' => {
|
84
|
+
description: 'Use the system\'s SSL certificate chain (if available).',
|
85
|
+
default: false
|
86
|
+
},
|
87
|
+
:'connection.http_open_timeout' => {
|
88
|
+
description: 'The HTTP open timeout when connecting to the server.',
|
89
|
+
default: 2
|
90
|
+
},
|
91
|
+
:'connection.http_read_timeout' => {
|
92
|
+
description: 'The HTTP read timeout when connecting to the server.',
|
93
|
+
default: 5
|
94
|
+
},
|
95
|
+
:'connection.proxy_host' => {
|
96
|
+
description: 'The proxy host to use when sending data.',
|
97
|
+
default: nil
|
98
|
+
},
|
99
|
+
:'connection.proxy_port' => {
|
100
|
+
description: 'The proxy port to use when sending data.',
|
101
|
+
default: nil
|
102
|
+
},
|
103
|
+
:'connection.proxy_user' => {
|
104
|
+
description: 'The proxy user to use when sending data.',
|
105
|
+
default: nil
|
106
|
+
},
|
107
|
+
:'connection.proxy_pass' => {
|
108
|
+
description: 'The proxy password to use when sending data.',
|
109
|
+
default: nil
|
110
|
+
},
|
111
|
+
:'request.filter_keys' => {
|
112
|
+
description: 'A list of keys to filter when sending request data.',
|
113
|
+
default: ['password'.freeze, 'password_confirmation'.freeze].freeze
|
114
|
+
},
|
115
|
+
:'request.exclude_keys' => {
|
116
|
+
description: 'A list of top-level keys to exclude when sending request data.',
|
117
|
+
default: [].freeze
|
118
|
+
},
|
119
|
+
:'user_informer.enabled' => {
|
120
|
+
description: 'Enable the UserInformer middleware.',
|
121
|
+
default: true
|
122
|
+
},
|
123
|
+
:'user_informer.info' => {
|
124
|
+
description: 'Replacement string for HTML comment in templates.',
|
125
|
+
default: 'Honeybadger Error {{error_id}}'.freeze
|
126
|
+
},
|
127
|
+
:'feedback.enabled' => {
|
128
|
+
description: 'Enable the UserFeedback middleware.',
|
129
|
+
default: true
|
130
|
+
},
|
131
|
+
:'exceptions.enabled' => {
|
132
|
+
description: 'Enable automatic reporting of exceptions.',
|
133
|
+
default: true
|
134
|
+
},
|
135
|
+
:'exceptions.ignore' => {
|
136
|
+
description: 'A list of exceptions to ignore.',
|
137
|
+
default: IGNORE_DEFAULT
|
138
|
+
},
|
139
|
+
:'exceptions.ignored_user_agents' => {
|
140
|
+
description: 'A list of user agents to ignore.',
|
141
|
+
default: [].freeze
|
142
|
+
},
|
143
|
+
:'exceptions.rescue_rake' => {
|
144
|
+
description: 'Enable rescuing exceptions in rake tasks.',
|
145
|
+
default: true
|
146
|
+
},
|
147
|
+
:'exceptions.source_radius' => {
|
148
|
+
description: 'The number of lines before and after the source when reporting snippets.',
|
149
|
+
default: 2
|
150
|
+
},
|
151
|
+
:'exceptions.local_variables' => {
|
152
|
+
description: 'Enable sending local variables. Requires binding_of_caller to be loaded.',
|
153
|
+
default: false
|
154
|
+
},
|
155
|
+
:'metrics.enabled' => {
|
156
|
+
description: 'Enable sending metrics.',
|
157
|
+
default: true
|
158
|
+
},
|
159
|
+
:'metrics.gc_profiler' => {
|
160
|
+
description: 'Enable sending GC metrics (GC::Profiler must be enabled)',
|
161
|
+
default: false
|
162
|
+
},
|
163
|
+
:'traces.enabled' => {
|
164
|
+
description: 'Enable sending traces.',
|
165
|
+
default: true
|
166
|
+
},
|
167
|
+
:'traces.threshold' => {
|
168
|
+
description: 'The threshold in seconds to send traces.',
|
169
|
+
default: 2000
|
170
|
+
}
|
171
|
+
}.freeze
|
172
|
+
|
173
|
+
DEFAULTS = Hash[OPTIONS.map{|k,v| [k, v[:default]] }].freeze
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Honeybadger
|
2
|
+
class Config
|
3
|
+
class Env < ::Hash
|
4
|
+
CONFIG_KEY = /\AHONEYBADGER_(.+)\Z/.freeze
|
5
|
+
CONFIG_MAPPING = Hash[DEFAULTS.keys.map {|k| [k.to_s.upcase.gsub(KEY_REPLACEMENT, '_'), k] }].freeze
|
6
|
+
ARRAY_VALUES = Regexp.new('\s*,\s*').freeze
|
7
|
+
|
8
|
+
def initialize(env = ENV)
|
9
|
+
env.each_pair do |k,v|
|
10
|
+
next unless k.match(CONFIG_KEY)
|
11
|
+
next if DISALLOWED_KEYS.include?(CONFIG_MAPPING[$1])
|
12
|
+
self[CONFIG_MAPPING[$1] || $1.downcase.to_sym] = cast_value(v)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def cast_value(value)
|
19
|
+
if value.match(ARRAY_VALUES)
|
20
|
+
return value.split(ARRAY_VALUES).map(&method(:cast_value))
|
21
|
+
end
|
22
|
+
|
23
|
+
case value
|
24
|
+
when /\Atrue\Z/
|
25
|
+
true
|
26
|
+
when /\Afalse\Z/
|
27
|
+
false
|
28
|
+
when /\Anil\Z/
|
29
|
+
nil
|
30
|
+
when /\A\d+\z/
|
31
|
+
value.to_i
|
32
|
+
when /\A\d+\.\d+\z/
|
33
|
+
value.to_f
|
34
|
+
else
|
35
|
+
value.to_s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
class Config
|
6
|
+
class Yaml < ::Hash
|
7
|
+
def initialize(path, env = 'production')
|
8
|
+
@path = Pathname.new(path)
|
9
|
+
|
10
|
+
if !@path.exist?
|
11
|
+
raise ConfigError, "The configuration file #{@path} was not found."
|
12
|
+
elsif !@path.file?
|
13
|
+
raise ConfigError, "The configuration file #{@path} is not a file."
|
14
|
+
elsif !@path.writable?
|
15
|
+
raise ConfigError, "The configuration file #{@path} is not writable."
|
16
|
+
else
|
17
|
+
yaml = YAML.load(@path.read)
|
18
|
+
override = yaml.delete(env)
|
19
|
+
update(dotify_keys(yaml.merge(override || {})))
|
20
|
+
end
|
21
|
+
|
22
|
+
rescue StandardError => e
|
23
|
+
raise ConfigError, "An unknown error occured: #{e.class} -- #{e.message}\n\t#{e.backtrace.first}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def dotify_keys(hash, key_prefix = nil)
|
29
|
+
{}.tap do |new_hash|
|
30
|
+
hash.each_pair do |k,v|
|
31
|
+
k = [key_prefix, k].compact.join('.')
|
32
|
+
if v.kind_of?(Hash)
|
33
|
+
new_hash.update(dotify_keys(v, k))
|
34
|
+
else
|
35
|
+
next if DISALLOWED_KEYS.include?(k.to_sym)
|
36
|
+
new_hash[k.to_sym] = v
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'honeybadger/version'
|
2
|
+
|
3
|
+
module Honeybadger
|
4
|
+
autoload :Agent, 'honeybadger/agent'
|
5
|
+
autoload :Backend, 'honeybadger/backend'
|
6
|
+
autoload :Backtrace, 'honeybadger/backtrace'
|
7
|
+
autoload :Config, 'honeybadger/config'
|
8
|
+
autoload :Logging, 'honeybadger/logging'
|
9
|
+
autoload :Notice, 'honeybadger/notice'
|
10
|
+
autoload :Worker, 'honeybadger/worker'
|
11
|
+
autoload :Trace, 'honeybadger/trace'
|
12
|
+
autoload :Plugin, 'honeybadger/plugin'
|
13
|
+
|
14
|
+
module Rack
|
15
|
+
autoload :ErrorNotifier, 'honeybadger/rack/error_notifier'
|
16
|
+
autoload :MetricsReporter, 'honeybadger/rack/metrics_reporter'
|
17
|
+
autoload :UserFeedback, 'honeybadger/rack/user_feedback'
|
18
|
+
autoload :UserInformer, 'honeybadger/rack/user_informer'
|
19
|
+
autoload :RequestHash, 'honeybadger/rack/request_hash'
|
20
|
+
end
|
21
|
+
|
22
|
+
module Util
|
23
|
+
autoload :Sanitizer, 'honeybadger/util/sanitizer'
|
24
|
+
autoload :RequestSanitizer, 'honeybadger/util/request_sanitizer'
|
25
|
+
autoload :Stats, 'honeybadger/util/stats'
|
26
|
+
autoload :HTTP, 'honeybadger/util/http'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Honeybadger
|
5
|
+
module Init
|
6
|
+
module Rails
|
7
|
+
class Railtie < ::Rails::Railtie
|
8
|
+
initializer 'honeybadger.install' do
|
9
|
+
config = Config.new(local_config)
|
10
|
+
if Honeybadger.start(config)
|
11
|
+
::Rails.application.config.middleware.tap do |middleware|
|
12
|
+
middleware.insert(0, 'Honeybadger::Rack::ErrorNotifier', config)
|
13
|
+
middleware.insert_before('Honeybadger::Rack::ErrorNotifier', 'Honeybadger::Rack::UserFeedback', config)
|
14
|
+
middleware.insert_before('Honeybadger::Rack::UserFeedback', 'Honeybadger::Rack::UserInformer', config)
|
15
|
+
end
|
16
|
+
|
17
|
+
if config[:'traces.enabled']
|
18
|
+
ActiveSupport::Notifications.subscribe('start_processing.action_controller') do |name, started, finished, id, data|
|
19
|
+
Trace.create(id)
|
20
|
+
end
|
21
|
+
|
22
|
+
ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
23
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
24
|
+
Trace.current.add_query(event) if Trace.current and event.name != 'SCHEMA'
|
25
|
+
end
|
26
|
+
|
27
|
+
ActiveSupport::Notifications.subscribe(/^render_(template|action|collection)\.action_view/) do |*args|
|
28
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
29
|
+
Trace.current.add(event) if Trace.current
|
30
|
+
end
|
31
|
+
|
32
|
+
ActiveSupport::Notifications.subscribe('net_http.request') do |*args|
|
33
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
34
|
+
Trace.current.add(event) if Trace.current
|
35
|
+
end
|
36
|
+
|
37
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
38
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
39
|
+
if Trace.current && event.payload[:controller] && event.payload[:action]
|
40
|
+
Trace.current.complete(event)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if config[:'metrics.enabled']
|
46
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
|
47
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
48
|
+
status = event.payload[:exception] ? 500 : event.payload[:status]
|
49
|
+
Agent.timing("app.request.#{status}", event.duration)
|
50
|
+
|
51
|
+
controller = event.payload[:controller]
|
52
|
+
action = event.payload[:action]
|
53
|
+
if controller && action
|
54
|
+
Agent.timing("app.controller.#{controller}.#{action}.total", event.duration)
|
55
|
+
Agent.timing("app.controller.#{controller}.#{action}.view", event.payload[:view_runtime]) if event.payload[:view_runtime]
|
56
|
+
Agent.timing("app.controller.#{controller}.#{action}.db", event.payload[:db_runtime]) if event.payload[:db_runtime]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def local_config
|
66
|
+
{
|
67
|
+
:root => ::Rails.root.to_s,
|
68
|
+
:env => ::Rails.env,
|
69
|
+
:'config.path' => ::Rails.root.join('config', 'honeybadger.yml'),
|
70
|
+
:logger => Logging::FormattedLogger.new(::Rails.logger),
|
71
|
+
:framework => :rails,
|
72
|
+
:api_key => secrets_api_key
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def secrets_api_key
|
77
|
+
if defined?(::Rails.application.secrets)
|
78
|
+
::Rails.application.secrets.honeybadger_api_key
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|