sentry-rails 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.craft.yml +19 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sentry/rails.rb +13 -0
- data/lib/sentry/rails/active_job.rb +58 -0
- data/lib/sentry/rails/backtrace_cleaner.rb +29 -0
- data/lib/sentry/rails/breadcrumb/active_support_logger.rb +27 -0
- data/lib/sentry/rails/capture_exception.rb +9 -0
- data/lib/sentry/rails/configuration.rb +40 -0
- data/lib/sentry/rails/controller_methods.rb +26 -0
- data/lib/sentry/rails/controller_transaction.rb +13 -0
- data/lib/sentry/rails/overrides/debug_exceptions_catcher.rb +19 -0
- data/lib/sentry/rails/overrides/streaming_reporter.rb +23 -0
- data/lib/sentry/rails/railtie.rb +65 -0
- data/lib/sentry/rails/version.rb +5 -0
- data/sentry-rails.gemspec +27 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 12812aa43ec08e1599d09ce9e0602cd141519dc50fccf6b6e91a6b01123898c6
|
4
|
+
data.tar.gz: e227fc53d69083c4844f7db7a8f2321d6d13c94fe7ae56f15c568e13de20aa90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e89fa75dff95ea2f9308e3250594104b3831b7578bddb80da23cde9ad15dacc0f4a1564777e2ab34acf358f16f7ee70c0900f33fac348346429f58ab732296f2
|
7
|
+
data.tar.gz: 1715da8885b92a56df96c48e80956d5a17d3759509a562967325f3a1be7beb7e5df893a8e0b81670c9591518f04e29e5e893c515213af446e9fa2084769ab177
|
data/.craft.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
minVersion: '0.13.2'
|
2
|
+
github:
|
3
|
+
owner: getsentry
|
4
|
+
repo: sentry-ruby
|
5
|
+
changelogPolicy: simple
|
6
|
+
preReleaseCommand: ruby ../.scripts/bump-version.rb
|
7
|
+
releaseBranchPrefix: release-sentry-rails
|
8
|
+
statusProvider:
|
9
|
+
name: github
|
10
|
+
artifactProvider:
|
11
|
+
name: github
|
12
|
+
targets:
|
13
|
+
- name: gem
|
14
|
+
- name: github
|
15
|
+
tagPrefix: sentry-rails
|
16
|
+
- name: registry
|
17
|
+
type: sdk
|
18
|
+
config:
|
19
|
+
canonical: 'gem:sentry-rails'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at stan001212@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in sentry-ruby.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
rails_version = ENV["RAILS_VERSION"]
|
7
|
+
rails_version = "6.0" if rails_version.nil?
|
8
|
+
|
9
|
+
gem "rails", "~> #{rails_version}"
|
10
|
+
gem "rspec-rails", "~> 4.0"
|
11
|
+
gem "codecov"
|
12
|
+
|
13
|
+
gem "rake", "~> 12.0"
|
14
|
+
gem "rspec", "~> 3.0"
|
15
|
+
|
16
|
+
gem "sidekiq"
|
17
|
+
|
18
|
+
gem "sentry-ruby", path: "../sentry-ruby"
|
19
|
+
|
20
|
+
gem "pry"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 st0012
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Sentry::Ruby
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sentry/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sentry-ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sentry-ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sentry-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/sentry-ruby/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Sentry::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sentry-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sentry/ruby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/sentry/rails.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "sentry"
|
2
|
+
require "sentry/rails/configuration"
|
3
|
+
require "sentry/rails/railtie"
|
4
|
+
|
5
|
+
module Sentry
|
6
|
+
module Rails
|
7
|
+
META = { "name" => "sentry.ruby.rails", "version" => Sentry::Rails::VERSION }.freeze
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.sdk_meta
|
11
|
+
Sentry::Rails::META
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module ActiveJobExtensions
|
4
|
+
ALREADY_SUPPORTED_SENTRY_ADAPTERS = %w(
|
5
|
+
ActiveJob::QueueAdapters::SidekiqAdapter
|
6
|
+
ActiveJob::QueueAdapters::DelayedJobAdapter
|
7
|
+
).freeze
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.class_eval do
|
11
|
+
around_perform do |job, block|
|
12
|
+
if already_supported_by_specific_integration?(job)
|
13
|
+
block.call
|
14
|
+
else
|
15
|
+
Sentry.with_scope do
|
16
|
+
capture_and_reraise_with_sentry(job, block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def capture_and_reraise_with_sentry(job, block)
|
24
|
+
block.call
|
25
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
26
|
+
rescue_handler_result = rescue_with_handler(e)
|
27
|
+
return rescue_handler_result if rescue_handler_result
|
28
|
+
|
29
|
+
Sentry.capture_exception(e, :extra => sentry_context(job))
|
30
|
+
raise e
|
31
|
+
end
|
32
|
+
|
33
|
+
def already_supported_by_specific_integration?(job)
|
34
|
+
ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.class.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def sentry_context(job)
|
38
|
+
ctx = {
|
39
|
+
:active_job => job.class.name,
|
40
|
+
:arguments => job.arguments,
|
41
|
+
:scheduled_at => job.scheduled_at,
|
42
|
+
:job_id => job.job_id,
|
43
|
+
:locale => job.locale
|
44
|
+
}
|
45
|
+
# Add provider_job_id details if Rails 5
|
46
|
+
if job.respond_to?(:provider_job_id)
|
47
|
+
ctx[:provider_job_id] = job.provider_job_id
|
48
|
+
end
|
49
|
+
|
50
|
+
ctx
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class ActiveJob::Base
|
57
|
+
include Sentry::Rails::ActiveJobExtensions
|
58
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "active_support/backtrace_cleaner"
|
2
|
+
require "active_support/core_ext/string/access"
|
3
|
+
|
4
|
+
module Sentry
|
5
|
+
module Rails
|
6
|
+
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
|
7
|
+
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/.freeze
|
8
|
+
RENDER_TEMPLATE_PATTERN = /:in `.*_\w+_{2,3}\d+_\d+'/.freeze
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
# we don't want any default silencers because they're too aggressive
|
13
|
+
remove_silencers!
|
14
|
+
|
15
|
+
@root = "#{Sentry.configuration.project_root}/"
|
16
|
+
add_filter do |line|
|
17
|
+
line.start_with?(@root) ? line.from(@root.size) : line
|
18
|
+
end
|
19
|
+
add_filter do |line|
|
20
|
+
if line =~ RENDER_TEMPLATE_PATTERN
|
21
|
+
line.sub(RENDER_TEMPLATE_PATTERN, "")
|
22
|
+
else
|
23
|
+
line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module Breadcrumb
|
4
|
+
module ActiveSupportLogger
|
5
|
+
class << self
|
6
|
+
def add(name, started, _finished, _unique_id, data)
|
7
|
+
Sentry.get_current_scope.breadcrumbs.record do |crumb|
|
8
|
+
crumb.data = data
|
9
|
+
crumb.category = name
|
10
|
+
crumb.timestamp = started.to_i
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def inject
|
15
|
+
@subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
|
16
|
+
add(name, started, finished, unique_id, data)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def detach
|
21
|
+
::ActiveSupport::Notifications.unsubscribe(@subscriber)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Sentry
|
2
|
+
class Configuration
|
3
|
+
attr_reader :rails
|
4
|
+
|
5
|
+
def post_initialization_callback
|
6
|
+
@rails = Sentry::Rails::Configuration.new
|
7
|
+
@excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::IGNORE_DEFAULT)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Rails
|
12
|
+
IGNORE_DEFAULT = [
|
13
|
+
'AbstractController::ActionNotFound',
|
14
|
+
'ActionController::BadRequest',
|
15
|
+
'ActionController::InvalidAuthenticityToken',
|
16
|
+
'ActionController::InvalidCrossOriginRequest',
|
17
|
+
'ActionController::MethodNotAllowed',
|
18
|
+
'ActionController::NotImplemented',
|
19
|
+
'ActionController::ParameterMissing',
|
20
|
+
'ActionController::RoutingError',
|
21
|
+
'ActionController::UnknownAction',
|
22
|
+
'ActionController::UnknownFormat',
|
23
|
+
'ActionController::UnknownHttpMethod',
|
24
|
+
'ActionDispatch::Http::Parameters::ParseError',
|
25
|
+
'ActiveJob::DeserializationError', # Can cause infinite loops
|
26
|
+
'ActiveRecord::RecordNotFound'
|
27
|
+
].freeze
|
28
|
+
class Configuration
|
29
|
+
# Rails catches exceptions in the ActionDispatch::ShowExceptions or
|
30
|
+
# ActionDispatch::DebugExceptions middlewares, depending on the environment.
|
31
|
+
# When `rails_report_rescued_exceptions` is true (it is by default), Sentry
|
32
|
+
# will report exceptions even when they are rescued by these middlewares.
|
33
|
+
attr_accessor :report_rescued_exceptions
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
@report_rescued_exceptions = true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module ControllerMethods
|
4
|
+
def capture_message(message, options = {})
|
5
|
+
with_request_scope do
|
6
|
+
Sentry.capture_message(message, **options)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def capture_exception(exception, options = {})
|
11
|
+
with_request_scope do
|
12
|
+
Sentry.capture_exception(exception, **options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def with_request_scope
|
19
|
+
Sentry.with_scope do |scope|
|
20
|
+
scope.set_rack_env(request.env)
|
21
|
+
yield
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module ControllerTransaction
|
4
|
+
def self.included(base)
|
5
|
+
base.prepend_around_action do |controller, block|
|
6
|
+
Sentry.get_current_scope.set_transaction_name("#{controller.class}##{controller.action_name}")
|
7
|
+
block.call
|
8
|
+
Sentry.get_current_scope.transaction_names.pop
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module Overrides
|
4
|
+
module DebugExceptionsCatcher
|
5
|
+
def render_exception(env_or_request, exception)
|
6
|
+
begin
|
7
|
+
env = env_or_request.respond_to?(:env) ? env_or_request.env : env_or_request
|
8
|
+
Sentry.with_scope do |scope|
|
9
|
+
scope.set_rack_env(env)
|
10
|
+
Sentry.capture_exception(exception)
|
11
|
+
end
|
12
|
+
rescue
|
13
|
+
end
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module Overrides
|
4
|
+
module StreamingReporter
|
5
|
+
def log_error(exception)
|
6
|
+
Sentry.capture_exception(exception)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module OldStreamingReporter
|
12
|
+
def self.included(base)
|
13
|
+
base.send(:alias_method_chain, :log_error, :raven)
|
14
|
+
end
|
15
|
+
|
16
|
+
def log_error_with_raven(exception)
|
17
|
+
Sentry.capture_exception(exception)
|
18
|
+
log_error_without_raven(exception)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "sentry/rails/capture_exception"
|
3
|
+
require "sentry/rails/backtrace_cleaner"
|
4
|
+
require "sentry/rails/controller_methods"
|
5
|
+
require "sentry/rails/controller_transaction"
|
6
|
+
require "sentry/rails/active_job"
|
7
|
+
require "sentry/rails/overrides/streaming_reporter"
|
8
|
+
|
9
|
+
module Sentry
|
10
|
+
class Railtie < ::Rails::Railtie
|
11
|
+
initializer "sentry.use_rack_middleware" do |app|
|
12
|
+
app.config.middleware.insert 0, Sentry::Rails::CaptureException
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer 'sentry.action_controller' do
|
16
|
+
ActiveSupport.on_load :action_controller do
|
17
|
+
include Sentry::Rails::ControllerMethods
|
18
|
+
include Sentry::Rails::ControllerTransaction
|
19
|
+
ActionController::Live.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
initializer 'sentry.action_view' do
|
24
|
+
ActiveSupport.on_load :action_view do
|
25
|
+
ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after_initialize do
|
30
|
+
Sentry.configuration.logger = ::Rails.logger
|
31
|
+
|
32
|
+
backtrace_cleaner = Sentry::Rails::BacktraceCleaner.new
|
33
|
+
|
34
|
+
Sentry.configuration.backtrace_cleanup_callback = lambda do |backtrace|
|
35
|
+
backtrace_cleaner.clean(backtrace)
|
36
|
+
end
|
37
|
+
|
38
|
+
if Sentry.configuration.breadcrumbs_logger.include?(:active_support_logger)
|
39
|
+
require 'sentry/rails/breadcrumb/active_support_logger'
|
40
|
+
Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject
|
41
|
+
end
|
42
|
+
|
43
|
+
if Sentry.configuration.rails.report_rescued_exceptions
|
44
|
+
require 'sentry/rails/overrides/debug_exceptions_catcher'
|
45
|
+
if defined?(::ActionDispatch::DebugExceptions)
|
46
|
+
exceptions_class = ::ActionDispatch::DebugExceptions
|
47
|
+
elsif defined?(::ActionDispatch::ShowExceptions)
|
48
|
+
exceptions_class = ::ActionDispatch::ShowExceptions
|
49
|
+
end
|
50
|
+
|
51
|
+
exceptions_class.send(:prepend, Sentry::Rails::Overrides::DebugExceptionsCatcher)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
initializer 'sentry.active_job' do
|
56
|
+
ActiveSupport.on_load :active_job do
|
57
|
+
require 'sentry/rails/active_job'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# rake_tasks do
|
62
|
+
# require 'sentry/integrations/tasks'
|
63
|
+
# end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "lib/sentry/rails/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "sentry-rails"
|
5
|
+
spec.version = Sentry::Rails::VERSION
|
6
|
+
spec.authors = ["Sentry Team"]
|
7
|
+
spec.description = spec.summary = "A gem that provides Rails integration for the Sentry error logger"
|
8
|
+
spec.email = "accounts@sentry.io"
|
9
|
+
spec.license = 'Apache-2.0'
|
10
|
+
spec.homepage = "https://github.com/getsentry/sentry-ruby"
|
11
|
+
|
12
|
+
spec.platform = Gem::Platform::RUBY
|
13
|
+
spec.required_ruby_version = '>= 2.4'
|
14
|
+
spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
15
|
+
spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "rails", ">= 5.0"
|
26
|
+
spec.add_dependency "sentry-ruby"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sentry-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sentry Team
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sentry-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A gem that provides Rails integration for the Sentry error logger
|
42
|
+
email: accounts@sentry.io
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files:
|
46
|
+
- README.md
|
47
|
+
- LICENSE.txt
|
48
|
+
files:
|
49
|
+
- ".craft.yml"
|
50
|
+
- ".gitignore"
|
51
|
+
- ".rspec"
|
52
|
+
- ".travis.yml"
|
53
|
+
- CHANGELOG.md
|
54
|
+
- CODE_OF_CONDUCT.md
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/console
|
60
|
+
- bin/setup
|
61
|
+
- lib/sentry/rails.rb
|
62
|
+
- lib/sentry/rails/active_job.rb
|
63
|
+
- lib/sentry/rails/backtrace_cleaner.rb
|
64
|
+
- lib/sentry/rails/breadcrumb/active_support_logger.rb
|
65
|
+
- lib/sentry/rails/capture_exception.rb
|
66
|
+
- lib/sentry/rails/configuration.rb
|
67
|
+
- lib/sentry/rails/controller_methods.rb
|
68
|
+
- lib/sentry/rails/controller_transaction.rb
|
69
|
+
- lib/sentry/rails/overrides/debug_exceptions_catcher.rb
|
70
|
+
- lib/sentry/rails/overrides/streaming_reporter.rb
|
71
|
+
- lib/sentry/rails/railtie.rb
|
72
|
+
- lib/sentry/rails/version.rb
|
73
|
+
- sentry-rails.gemspec
|
74
|
+
homepage: https://github.com/getsentry/sentry-ruby
|
75
|
+
licenses:
|
76
|
+
- Apache-2.0
|
77
|
+
metadata:
|
78
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby
|
79
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby
|
80
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.4'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.0.3
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: A gem that provides Rails integration for the Sentry error logger
|
100
|
+
test_files: []
|