sentry-raven 2.7.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.craft.yml +15 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- data/.github/pull_request_template.md +16 -0
- data/.github/workflows/test.yml +92 -0
- data/.github/workflows/zeus_upload.yml +32 -0
- data/.gitignore +3 -1
- data/.gitmodules +0 -3
- data/.rubocop.yml +50 -12
- data/.scripts/bump-version.sh +9 -0
- data/{changelog.md → CHANGELOG.md} +238 -1
- data/CONTRIBUTING.md +71 -0
- data/Gemfile +21 -26
- data/README.md +42 -22
- data/lib/raven/backtrace.rb +9 -5
- data/lib/raven/base.rb +8 -3
- data/lib/raven/breadcrumbs.rb +1 -1
- data/lib/raven/breadcrumbs/{activesupport.rb → active_support_logger.rb} +9 -3
- data/lib/raven/breadcrumbs/logger.rb +2 -92
- data/lib/raven/breadcrumbs/sentry_logger.rb +73 -0
- data/lib/raven/cli.rb +10 -21
- data/lib/raven/client.rb +37 -11
- data/lib/raven/configuration.rb +141 -20
- data/lib/raven/context.rb +13 -8
- data/lib/raven/core_ext/object/deep_dup.rb +57 -0
- data/lib/raven/core_ext/object/duplicable.rb +153 -0
- data/lib/raven/event.rb +29 -37
- data/lib/raven/helpers/deprecation_helper.rb +17 -0
- data/lib/raven/instance.rb +30 -8
- data/lib/raven/integrations/delayed_job.rb +16 -16
- data/lib/raven/integrations/rack-timeout.rb +7 -4
- data/lib/raven/integrations/rack.rb +19 -5
- data/lib/raven/integrations/rails.rb +13 -3
- data/lib/raven/integrations/rails/active_job.rb +11 -7
- data/lib/raven/integrations/rails/backtrace_cleaner.rb +29 -0
- data/lib/raven/integrations/rails/controller_transaction.rb +1 -1
- data/lib/raven/integrations/rails/overrides/debug_exceptions_catcher.rb +2 -2
- data/lib/raven/integrations/sidekiq.rb +4 -78
- data/lib/raven/integrations/sidekiq/cleanup_middleware.rb +13 -0
- data/lib/raven/integrations/sidekiq/error_handler.rb +38 -0
- data/lib/raven/interface.rb +2 -2
- data/lib/raven/interfaces/stack_trace.rb +1 -1
- data/lib/raven/linecache.rb +5 -2
- data/lib/raven/logger.rb +3 -2
- data/lib/raven/processor/cookies.rb +16 -6
- data/lib/raven/processor/post_data.rb +2 -0
- data/lib/raven/processor/removecircularreferences.rb +3 -1
- data/lib/raven/processor/sanitizedata.rb +65 -17
- data/lib/raven/processor/utf8conversion.rb +3 -1
- data/lib/raven/transports.rb +4 -0
- data/lib/raven/transports/http.rb +5 -7
- data/lib/raven/transports/stdout.rb +20 -0
- data/lib/raven/utils/context_filter.rb +42 -0
- data/lib/raven/utils/exception_cause_chain.rb +20 -0
- data/lib/raven/utils/real_ip.rb +1 -1
- data/lib/raven/version.rb +2 -2
- data/lib/sentry-raven-without-integrations.rb +6 -1
- data/lib/sentry_raven_without_integrations.rb +1 -0
- data/sentry-raven.gemspec +3 -4
- data/sentry-ruby/.gitignore +11 -0
- data/sentry-ruby/.rspec +3 -0
- data/sentry-ruby/.travis.yml +6 -0
- data/sentry-ruby/CODE_OF_CONDUCT.md +74 -0
- data/sentry-ruby/Gemfile +9 -0
- data/sentry-ruby/LICENSE.txt +21 -0
- data/sentry-ruby/README.md +44 -0
- data/sentry-ruby/Rakefile +6 -0
- data/sentry-ruby/bin/console +14 -0
- data/sentry-ruby/bin/setup +8 -0
- data/sentry-ruby/examples/rails-6.0/.browserslistrc +1 -0
- data/sentry-ruby/examples/rails-6.0/.gitignore +35 -0
- data/sentry-ruby/examples/rails-6.0/Gemfile +58 -0
- data/sentry-ruby/examples/rails-6.0/README.md +23 -0
- data/sentry-ruby/examples/rails-6.0/Rakefile +6 -0
- data/sentry-ruby/examples/rails-6.0/app/assets/config/manifest.js +2 -0
- data/sentry-ruby/examples/rails-6.0/app/assets/images/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/app/assets/stylesheets/application.css +15 -0
- data/sentry-ruby/examples/rails-6.0/app/channels/application_cable/channel.rb +4 -0
- data/sentry-ruby/examples/rails-6.0/app/channels/application_cable/connection.rb +4 -0
- data/sentry-ruby/examples/rails-6.0/app/controllers/application_controller.rb +2 -0
- data/sentry-ruby/examples/rails-6.0/app/controllers/concerns/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/app/controllers/welcome_controller.rb +23 -0
- data/sentry-ruby/examples/rails-6.0/app/helpers/application_helper.rb +2 -0
- data/sentry-ruby/examples/rails-6.0/app/javascript/channels/consumer.js +6 -0
- data/sentry-ruby/examples/rails-6.0/app/javascript/channels/index.js +5 -0
- data/sentry-ruby/examples/rails-6.0/app/javascript/packs/application.js +17 -0
- data/sentry-ruby/examples/rails-6.0/app/jobs/application_job.rb +7 -0
- data/sentry-ruby/examples/rails-6.0/app/mailers/application_mailer.rb +4 -0
- data/sentry-ruby/examples/rails-6.0/app/models/application_record.rb +3 -0
- data/sentry-ruby/examples/rails-6.0/app/models/concerns/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/app/views/layouts/application.html.erb +15 -0
- data/sentry-ruby/examples/rails-6.0/app/views/layouts/mailer.html.erb +13 -0
- data/sentry-ruby/examples/rails-6.0/app/views/layouts/mailer.text.erb +1 -0
- data/sentry-ruby/examples/rails-6.0/app/views/welcome/report_demo.html.erb +22 -0
- data/sentry-ruby/examples/rails-6.0/app/views/welcome/view_error.html.erb +1 -0
- data/sentry-ruby/examples/rails-6.0/app/workers/error_worker.rb +7 -0
- data/sentry-ruby/examples/rails-6.0/babel.config.js +72 -0
- data/sentry-ruby/examples/rails-6.0/bin/bundle +114 -0
- data/sentry-ruby/examples/rails-6.0/bin/rails +9 -0
- data/sentry-ruby/examples/rails-6.0/bin/rake +9 -0
- data/sentry-ruby/examples/rails-6.0/bin/setup +36 -0
- data/sentry-ruby/examples/rails-6.0/bin/spring +17 -0
- data/sentry-ruby/examples/rails-6.0/bin/webpack +18 -0
- data/sentry-ruby/examples/rails-6.0/bin/webpack-dev-server +18 -0
- data/sentry-ruby/examples/rails-6.0/bin/yarn +11 -0
- data/sentry-ruby/examples/rails-6.0/config.ru +5 -0
- data/sentry-ruby/examples/rails-6.0/config/application.rb +28 -0
- data/sentry-ruby/examples/rails-6.0/config/boot.rb +4 -0
- data/sentry-ruby/examples/rails-6.0/config/cable.yml +10 -0
- data/sentry-ruby/examples/rails-6.0/config/credentials.yml.enc +1 -0
- data/sentry-ruby/examples/rails-6.0/config/database.yml +25 -0
- data/sentry-ruby/examples/rails-6.0/config/environment.rb +5 -0
- data/sentry-ruby/examples/rails-6.0/config/environments/development.rb +62 -0
- data/sentry-ruby/examples/rails-6.0/config/environments/production.rb +112 -0
- data/sentry-ruby/examples/rails-6.0/config/environments/test.rb +48 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/application_controller_renderer.rb +8 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/assets.rb +14 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/backtrace_silencers.rb +7 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/content_security_policy.rb +30 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/cookies_serializer.rb +5 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/inflections.rb +16 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/mime_types.rb +4 -0
- data/sentry-ruby/examples/rails-6.0/config/initializers/wrap_parameters.rb +14 -0
- data/sentry-ruby/examples/rails-6.0/config/locales/en.yml +33 -0
- data/sentry-ruby/examples/rails-6.0/config/puma.rb +38 -0
- data/sentry-ruby/examples/rails-6.0/config/routes.rb +10 -0
- data/sentry-ruby/examples/rails-6.0/config/spring.rb +6 -0
- data/sentry-ruby/examples/rails-6.0/config/storage.yml +34 -0
- data/sentry-ruby/examples/rails-6.0/config/webpack/development.js +5 -0
- data/sentry-ruby/examples/rails-6.0/config/webpack/environment.js +3 -0
- data/sentry-ruby/examples/rails-6.0/config/webpack/production.js +5 -0
- data/sentry-ruby/examples/rails-6.0/config/webpack/test.js +5 -0
- data/sentry-ruby/examples/rails-6.0/config/webpacker.yml +96 -0
- data/sentry-ruby/examples/rails-6.0/db/seeds.rb +7 -0
- data/sentry-ruby/examples/rails-6.0/lib/assets/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/lib/tasks/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/package.json +15 -0
- data/sentry-ruby/examples/rails-6.0/postcss.config.js +12 -0
- data/sentry-ruby/examples/rails-6.0/public/404.html +67 -0
- data/sentry-ruby/examples/rails-6.0/public/422.html +67 -0
- data/sentry-ruby/examples/rails-6.0/public/500.html +66 -0
- data/sentry-ruby/examples/rails-6.0/public/apple-touch-icon-precomposed.png +0 -0
- data/sentry-ruby/examples/rails-6.0/public/apple-touch-icon.png +0 -0
- data/sentry-ruby/examples/rails-6.0/public/favicon.ico +0 -0
- data/sentry-ruby/examples/rails-6.0/public/robots.txt +1 -0
- data/sentry-ruby/examples/rails-6.0/storage/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/application_system_test_case.rb +5 -0
- data/sentry-ruby/examples/rails-6.0/test/channels/application_cable/connection_test.rb +11 -0
- data/sentry-ruby/examples/rails-6.0/test/controllers/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/fixtures/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/fixtures/files/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/helpers/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/integration/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/mailers/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/models/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/system/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/test/test_helper.rb +13 -0
- data/sentry-ruby/examples/rails-6.0/vendor/.keep +0 -0
- data/sentry-ruby/examples/rails-6.0/yarn.lock +7508 -0
- data/sentry-ruby/lib/sentry.rb +16 -0
- data/sentry-ruby/lib/sentry/backtrace.rb +128 -0
- data/sentry-ruby/lib/sentry/client.rb +162 -0
- data/sentry-ruby/lib/sentry/client/state.rb +40 -0
- data/sentry-ruby/lib/sentry/configuration.rb +533 -0
- data/sentry-ruby/lib/sentry/event.rb +209 -0
- data/sentry-ruby/lib/sentry/interface.rb +31 -0
- data/sentry-ruby/lib/sentry/interfaces/exception.rb +15 -0
- data/sentry-ruby/lib/sentry/interfaces/http.rb +16 -0
- data/sentry-ruby/lib/sentry/interfaces/message.rb +18 -0
- data/sentry-ruby/lib/sentry/interfaces/single_exception.rb +14 -0
- data/sentry-ruby/lib/sentry/interfaces/stack_trace.rb +69 -0
- data/sentry-ruby/lib/sentry/linecache.rb +44 -0
- data/sentry-ruby/lib/sentry/logger.rb +20 -0
- data/sentry-ruby/lib/sentry/transports.rb +19 -0
- data/sentry-ruby/lib/sentry/transports/dummy.rb +16 -0
- data/sentry-ruby/lib/sentry/transports/http.rb +66 -0
- data/sentry-ruby/lib/sentry/transports/stdout.rb +20 -0
- data/sentry-ruby/lib/sentry/utils/deep_merge.rb +22 -0
- data/sentry-ruby/lib/sentry/utils/exception_cause_chain.rb +20 -0
- data/sentry-ruby/lib/sentry/version.rb +3 -0
- data/sentry-ruby/sentry-ruby.gemspec +26 -0
- data/sentry-ruby/spec/sentry/backtrace_spec.rb +38 -0
- data/sentry-ruby/spec/sentry/client_spec.rb +443 -0
- data/sentry-ruby/spec/sentry/configuration_spec.rb +400 -0
- data/sentry-ruby/spec/sentry/event_spec.rb +238 -0
- data/sentry-ruby/spec/sentry/interface_spec.rb +38 -0
- data/sentry-ruby/spec/sentry/interfaces/stack_trace_spec.rb +11 -0
- data/sentry-ruby/spec/sentry/linecache_spec.rb +40 -0
- data/sentry-ruby/spec/sentry/transports/http_spec.rb +57 -0
- data/sentry-ruby/spec/sentry/transports/stdout_spec.rb +11 -0
- data/sentry-ruby/spec/sentry_spec.rb +9 -0
- data/sentry-ruby/spec/spec_helper.rb +49 -0
- data/sentry-ruby/spec/support/linecache.txt +6 -0
- metadata +160 -31
- data/.travis.yml +0 -47
- data/docs/Makefile +0 -130
- data/docs/breadcrumbs.rst +0 -51
- data/docs/conf.py +0 -228
- data/docs/config.rst +0 -260
- data/docs/context.rst +0 -141
- data/docs/index.rst +0 -113
- data/docs/install.rst +0 -40
- data/docs/integrations/heroku.rst +0 -11
- data/docs/integrations/index.rst +0 -59
- data/docs/integrations/puma.rst +0 -30
- data/docs/integrations/rack.rst +0 -27
- data/docs/integrations/rails.rst +0 -62
- data/docs/make.bat +0 -155
- data/docs/processors.rst +0 -124
- data/docs/sentry-doc-config.json +0 -31
- data/docs/usage.rst +0 -176
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://sentry.io" target="_blank" align="center">
|
3
|
+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
|
4
|
+
</a>
|
5
|
+
<br />
|
6
|
+
</p>
|
7
|
+
|
8
|
+
# Contributing
|
9
|
+
|
10
|
+
You can contribute this project in the following ways:
|
11
|
+
|
12
|
+
- File a [bug report] or propose a feature
|
13
|
+
- Open a PR for bug fixes or implementing requested features
|
14
|
+
- Give feedback to opened issues/pull requests
|
15
|
+
- Test the latest version - `gem 'sentry-raven', github: 'getsentry/raven-ruby'`
|
16
|
+
- Contribute documentation in the [document repo]
|
17
|
+
|
18
|
+
|
19
|
+
And if you have any questions, please feel free to reach out on [Discord].
|
20
|
+
|
21
|
+
|
22
|
+
[bug report]: https://github.com/getsentry/raven-ruby/issues/new?template=bug_report.md
|
23
|
+
[document repo]: https://github.com/getsentry/sentry-docs
|
24
|
+
[Discord]: https://discord.gg/Ww9hbqr
|
25
|
+
|
26
|
+
## How To Contribute
|
27
|
+
|
28
|
+
### Running Tests
|
29
|
+
|
30
|
+
#### RAILS_VERSION
|
31
|
+
|
32
|
+
Because this SDK supports multiple versions of Rails, or even without Rails, you might want to run your test against different versions of Rails.
|
33
|
+
|
34
|
+
You can do this by changing the `RAILS_VERSION` environment variable:
|
35
|
+
|
36
|
+
|
37
|
+
```
|
38
|
+
$ echo RAILS_VERSION=6.0
|
39
|
+
$ bundle update # this is necessary if you're switching between Rails versions
|
40
|
+
$ bundle exec rake
|
41
|
+
```
|
42
|
+
|
43
|
+
If not specified, it runs tests against `Rails 5.2`.
|
44
|
+
|
45
|
+
And if you don't want to run the Rails related test cases, you can use `RAILS_VERSION=0`
|
46
|
+
|
47
|
+
```
|
48
|
+
$ RAILS_VERSION=0 bundle exec rake # runs without Rails related test cases
|
49
|
+
```
|
50
|
+
|
51
|
+
### Testing Your Change Against Example Rails Apps
|
52
|
+
|
53
|
+
We have a few example apps for different Rails versions under the `/examples` folder. You can use them to perform an end-to-end testing on your changes (just remember to change the DSN to your project's).
|
54
|
+
|
55
|
+
At this moment, we recommend testing against the [Rails 6 example](https://github.com/getsentry/raven-ruby/tree/master/examples/rails-6.0) first. Please read its readme to see what kind of testing you can perform with it.
|
56
|
+
|
57
|
+
|
58
|
+
## Making a release
|
59
|
+
|
60
|
+
Install and use `craft`: https://github.com/getsentry/craft
|
61
|
+
|
62
|
+
Make sure the `CHANGELOG.md` is update and latest `master` contains all changes.
|
63
|
+
|
64
|
+
Run:
|
65
|
+
|
66
|
+
```bash
|
67
|
+
craft prepare x.x.x
|
68
|
+
```
|
69
|
+
|
70
|
+
Where `x.x.x` stands for the version you want to release.
|
71
|
+
Afterwards reach out to an employee of Sentry, they will cut a release by running the `publish` process of `craft`.
|
data/Gemfile
CHANGED
@@ -2,37 +2,32 @@ source "https://rubygems.org/"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
gem "rspec-rails"
|
8
|
-
elsif ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 0)
|
9
|
-
# no-op. No Rails.
|
10
|
-
else
|
11
|
-
gem "rails", "< 6"
|
12
|
-
gem "rspec-rails"
|
13
|
-
end
|
5
|
+
rails_version = ENV["RAILS_VERSION"]
|
6
|
+
rails_version = "5.2" if rails_version.nil?
|
14
7
|
|
15
|
-
if
|
16
|
-
gem "
|
17
|
-
gem "
|
18
|
-
gem "rack", "~> 1.6.8"
|
19
|
-
gem "sidekiq", "< 3.2"
|
20
|
-
gem "rack-timeout", "0.3.0"
|
21
|
-
else
|
22
|
-
gem "rack"
|
23
|
-
gem "sidekiq"
|
24
|
-
gem "rack-timeout"
|
8
|
+
if rails_version.to_f != 0
|
9
|
+
gem "rails", "~> #{rails_version}"
|
10
|
+
gem "rspec-rails", "~> 4.0"
|
25
11
|
end
|
12
|
+
|
13
|
+
gem "sidekiq"
|
14
|
+
|
15
|
+
gem "rack"
|
16
|
+
gem "rack-timeout"
|
17
|
+
|
26
18
|
gem "pry"
|
27
|
-
gem "pry-coolline"
|
28
19
|
gem "benchmark-ips"
|
29
|
-
gem "
|
20
|
+
gem "benchmark_driver"
|
21
|
+
gem "benchmark-ipsa"
|
22
|
+
gem "benchmark-memory"
|
30
23
|
gem "ruby-prof", platform: :mri
|
31
|
-
gem "rake"
|
32
|
-
gem "rubocop", "~> 0.
|
33
|
-
gem "rspec"
|
34
|
-
gem "capybara" # rspec system tests
|
24
|
+
gem "rake", "> 12"
|
25
|
+
gem "rubocop", "~> 0.81.0"
|
26
|
+
gem "rspec", "~> 3.9.0"
|
27
|
+
gem "capybara", "~> 3.15.0" # rspec system tests
|
35
28
|
gem "puma" # rspec system tests
|
36
29
|
|
37
30
|
gem "timecop"
|
38
|
-
gem "test-unit"
|
31
|
+
gem "test-unit"
|
32
|
+
gem "simplecov"
|
33
|
+
gem "codecov"
|
data/README.md
CHANGED
@@ -1,21 +1,32 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<
|
2
|
+
<a href="https://sentry.io" target="_blank" align="center">
|
3
|
+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
|
4
|
+
</a>
|
5
|
+
<br>
|
3
6
|
</p>
|
4
7
|
|
5
8
|
# Raven-Ruby, the Ruby Client for Sentry
|
6
9
|
|
10
|
+
### 🚧 We're restructuring this SDK for the [version 4.0](https://github.com/getsentry/raven-ruby/issues/1029) 🚧
|
11
|
+
|
12
|
+
---
|
13
|
+
|
14
|
+
|
7
15
|
[![Gem Version](https://img.shields.io/gem/v/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven)
|
8
|
-
|
16
|
+
![Build Status](https://github.com/getsentry/raven-ruby/workflows/Test/badge.svg)
|
17
|
+
[![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/raven-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/raven-ruby/branch/master)
|
9
18
|
[![Gem](https://img.shields.io/gem/dt/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven/)
|
19
|
+
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-raven&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-raven&package-manager=bundler&version-scheme=semver)
|
10
20
|
|
11
21
|
|
12
|
-
[Documentation](https://docs.
|
22
|
+
[Documentation](https://docs.sentry.io/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/raven-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
|
13
23
|
|
14
24
|
The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
|
15
25
|
|
26
|
+
|
16
27
|
## Requirements
|
17
28
|
|
18
|
-
We test on Ruby
|
29
|
+
We test on Ruby 2.3, 2.4, 2.5, 2.6 and 2.7 at the latest patchlevel/teeny version. We also support JRuby 9.0. Our Rails integration works with Rails 4.2+, including Rails 5 and Rails 6.
|
19
30
|
|
20
31
|
## Getting Started
|
21
32
|
|
@@ -25,18 +36,18 @@ We test on Ruby 1.9, 2.2, 2.3, and 2.4 at the latest patchlevel/teeny version. W
|
|
25
36
|
gem "sentry-raven"
|
26
37
|
```
|
27
38
|
|
28
|
-
### Raven only runs when
|
39
|
+
### Raven only runs when Sentry DSN is set
|
29
40
|
|
30
41
|
Raven will capture and send exceptions to the Sentry server whenever its DSN is set. This makes environment-based configuration easy - if you don't want to send errors in a certain environment, just don't set the DSN in that environment!
|
31
42
|
|
32
43
|
```bash
|
33
44
|
# Set your SENTRY_DSN environment variable.
|
34
|
-
export SENTRY_DSN=http://public
|
45
|
+
export SENTRY_DSN=http://public@example.com/project-id
|
35
46
|
```
|
36
47
|
```ruby
|
37
|
-
# Or you can configure the client in the code
|
48
|
+
# Or you can configure the client in the code.
|
38
49
|
Raven.configure do |config|
|
39
|
-
config.dsn = 'http://public
|
50
|
+
config.dsn = 'http://public@example.com/project-id'
|
40
51
|
end
|
41
52
|
```
|
42
53
|
|
@@ -44,11 +55,11 @@ end
|
|
44
55
|
|
45
56
|
**Raven ignores some exceptions by default** - most of these are related to 404s or controller actions not being found. [For a complete list, see the `IGNORE_DEFAULT` constant](https://github.com/getsentry/raven-ruby/blob/master/lib/raven/configuration.rb).
|
46
57
|
|
47
|
-
Raven doesn't report POST data or cookies by default. In addition, it will attempt to remove any obviously sensitive data, such as credit card or Social Security numbers. For more information about how Sentry processes your data, [check out the documentation on the `processors` config setting.](https://docs.
|
58
|
+
Raven doesn't report POST data or cookies by default. In addition, it will attempt to remove any obviously sensitive data, such as credit card or Social Security numbers. For more information about how Sentry processes your data, [check out the documentation on the `processors` config setting.](https://docs.sentry.io/platforms/ruby/config/)
|
48
59
|
|
49
60
|
### Usage
|
50
61
|
|
51
|
-
**If you use Rails, you're already done - no more configuration required!** Check [Integrations](https://docs.
|
62
|
+
**If you use Rails, you're already done - no more configuration required!** Check [Integrations](https://docs.sentry.io/platforms/ruby/integrations/) for more details on other gems Sentry integrates with automatically.
|
52
63
|
|
53
64
|
Otherwise, Raven supports two methods of capturing exceptions:
|
54
65
|
|
@@ -100,33 +111,42 @@ end
|
|
100
111
|
If Raven fails to send an event to Sentry for any reason (either the Sentry server has returned a 4XX or 5XX response), this Proc or lambda will be called.
|
101
112
|
|
102
113
|
```ruby
|
103
|
-
config.transport_failure_callback = lambda { |event|
|
104
|
-
AdminMailer.email_admins("Oh god, it's on fire!", event).deliver_later
|
114
|
+
config.transport_failure_callback = lambda { |event, error|
|
115
|
+
AdminMailer.email_admins("Oh god, it's on fire because #{error.message}!", event).deliver_later
|
105
116
|
}
|
106
117
|
```
|
107
118
|
|
108
119
|
#### Context
|
109
120
|
|
110
|
-
Much of the usefulness of Sentry comes from additional context data with the events. Raven makes this very convenient by providing methods to set thread local context data that is then submitted automatically with all events
|
111
|
-
|
112
|
-
There are three primary methods for providing request context:
|
121
|
+
Much of the usefulness of Sentry comes from additional context data with the events. Raven makes this very convenient by providing methods to set thread local context data that is then submitted automatically with all events:
|
113
122
|
|
114
123
|
```ruby
|
115
|
-
# bind the logged in user
|
116
124
|
Raven.user_context email: 'foo@example.com'
|
117
125
|
|
118
|
-
|
119
|
-
|
126
|
+
Raven.tags.merge!(interesting: 'yes')
|
127
|
+
|
128
|
+
Raven.extra.merge!(additional_info: 'foo')
|
129
|
+
```
|
130
|
+
|
131
|
+
You can also use `tags_context` and `extra_context` to provide scoped information:
|
120
132
|
|
121
|
-
|
122
|
-
Raven.
|
133
|
+
```ruby
|
134
|
+
Raven.tags_context(interesting: 'yes') do
|
135
|
+
# the `interesting: 'yes'` tag will only present in the requests sent inside the block
|
136
|
+
Raven.capture_exception(exception)
|
137
|
+
end
|
138
|
+
|
139
|
+
Raven.extra_context(additional_info: 'foo') do
|
140
|
+
# same as above, the `additional_info` will only present in this request
|
141
|
+
Raven.capture_exception(exception)
|
142
|
+
end
|
123
143
|
```
|
124
144
|
|
125
145
|
For more information, see [Context](https://docs.sentry.io/clients/ruby/context/).
|
126
146
|
|
127
147
|
## More Information
|
128
148
|
|
129
|
-
* [Documentation](https://docs.
|
149
|
+
* [Documentation](https://docs.sentry.io/clients/ruby/)
|
130
150
|
* [Bug Tracker](https://github.com/getsentry/raven-ruby/issues)
|
131
151
|
* [Forum](https://forum.sentry.io/)
|
132
|
-
|
152
|
+
- [Discord](https://discord.gg/ez5KZN7)
|
data/lib/raven/backtrace.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## Inspired by Rails' and Airbrake's backtrace parsers.
|
2
4
|
|
3
5
|
module Raven
|
@@ -5,16 +7,16 @@ module Raven
|
|
5
7
|
class Backtrace
|
6
8
|
# Handles backtrace parsing line by line
|
7
9
|
class Line
|
8
|
-
RB_EXTENSION = ".rb"
|
10
|
+
RB_EXTENSION = ".rb"
|
9
11
|
# regexp (optional leading X: on windows, or JRuby9000 class-prefix)
|
10
12
|
RUBY_INPUT_FORMAT = /
|
11
13
|
^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>):
|
12
14
|
(\d+)
|
13
15
|
(?: :in \s `([^']+)')?$
|
14
|
-
/x
|
16
|
+
/x.freeze
|
15
17
|
|
16
18
|
# org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
|
17
|
-
JAVA_INPUT_FORMAT = /^(.+)\.([^\.]+)\(([^\:]+)\:(\d+)\)
|
19
|
+
JAVA_INPUT_FORMAT = /^(.+)\.([^\.]+)\(([^\:]+)\:(\d+)\)$/.freeze
|
18
20
|
|
19
21
|
# The file portion of the line (such as app/models/user.rb)
|
20
22
|
attr_reader :file
|
@@ -74,7 +76,7 @@ module Raven
|
|
74
76
|
|
75
77
|
def self.in_app_pattern
|
76
78
|
@in_app_pattern ||= begin
|
77
|
-
project_root = Raven.configuration.project_root
|
79
|
+
project_root = Raven.configuration.project_root&.to_s
|
78
80
|
Regexp.new("^(#{project_root}/)?#{Raven.configuration.app_dirs_pattern || APP_DIRS_PATTERN}")
|
79
81
|
end
|
80
82
|
end
|
@@ -84,7 +86,7 @@ module Raven
|
|
84
86
|
attr_writer :file, :number, :method, :module_name
|
85
87
|
end
|
86
88
|
|
87
|
-
APP_DIRS_PATTERN = /(bin|exe|app|config|lib|test)
|
89
|
+
APP_DIRS_PATTERN = /(bin|exe|app|config|lib|test)/.freeze
|
88
90
|
|
89
91
|
# holder for an Array of Backtrace::Line instances
|
90
92
|
attr_reader :lines
|
@@ -92,6 +94,8 @@ module Raven
|
|
92
94
|
def self.parse(backtrace, opts = {})
|
93
95
|
ruby_lines = backtrace.is_a?(Array) ? backtrace : backtrace.split(/\n\s*/)
|
94
96
|
|
97
|
+
ruby_lines = opts[:configuration].backtrace_cleanup_callback.call(ruby_lines) if opts[:configuration]&.backtrace_cleanup_callback
|
98
|
+
|
95
99
|
filters = opts[:filters] || []
|
96
100
|
filtered_lines = ruby_lines.to_a.map do |line|
|
97
101
|
filters.reduce(line) do |nested_line, proc|
|
data/lib/raven/base.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'raven/version'
|
2
|
+
require "raven/helpers/deprecation_helper"
|
3
|
+
require 'raven/core_ext/object/deep_dup'
|
2
4
|
require 'raven/backtrace'
|
3
5
|
require 'raven/breadcrumbs'
|
4
6
|
require 'raven/processor'
|
@@ -23,6 +25,7 @@ require 'raven/transports'
|
|
23
25
|
require 'raven/transports/http'
|
24
26
|
require 'raven/utils/deep_merge'
|
25
27
|
require 'raven/utils/real_ip'
|
28
|
+
require 'raven/utils/exception_cause_chain'
|
26
29
|
require 'raven/instance'
|
27
30
|
|
28
31
|
require 'forwardable'
|
@@ -84,12 +87,13 @@ module Raven
|
|
84
87
|
|
85
88
|
def load_integration(integration)
|
86
89
|
require "raven/integrations/#{integration}"
|
87
|
-
rescue Exception =>
|
88
|
-
logger.warn "Unable to load raven/integrations/#{integration}: #{
|
90
|
+
rescue Exception => e
|
91
|
+
logger.warn "Unable to load raven/integrations/#{integration}: #{e}"
|
89
92
|
end
|
90
93
|
|
91
94
|
def safely_prepend(module_name, opts = {})
|
92
95
|
return if opts[:to].nil? || opts[:from].nil?
|
96
|
+
|
93
97
|
if opts[:to].respond_to?(:prepend, true)
|
94
98
|
opts[:to].send(:prepend, opts[:from].const_get(module_name))
|
95
99
|
else
|
@@ -99,7 +103,8 @@ module Raven
|
|
99
103
|
|
100
104
|
def sys_command(command)
|
101
105
|
result = `#{command} 2>&1` rescue nil
|
102
|
-
return if result.nil? || result.empty? || $CHILD_STATUS.exitstatus != 0
|
106
|
+
return if result.nil? || result.empty? || ($CHILD_STATUS && $CHILD_STATUS.exitstatus != 0)
|
107
|
+
|
103
108
|
result.strip
|
104
109
|
end
|
105
110
|
end
|
data/lib/raven/breadcrumbs.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Raven
|
2
|
-
module
|
3
|
-
|
2
|
+
module Breadcrumbs
|
3
|
+
module ActiveSupportLogger
|
4
|
+
class << self
|
4
5
|
def add(name, started, _finished, _unique_id, data)
|
5
6
|
Raven.breadcrumbs.record do |crumb|
|
6
7
|
crumb.data = data
|
@@ -10,10 +11,15 @@ module Raven
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def inject
|
13
|
-
ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
|
14
|
+
@subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
|
14
15
|
add(name, started, finished, unique_id, data)
|
15
16
|
end
|
16
17
|
end
|
18
|
+
|
19
|
+
def detach
|
20
|
+
::ActiveSupport::Notifications.unsubscribe(@subscriber)
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -1,93 +1,3 @@
|
|
1
|
-
|
1
|
+
DeprecationHelper.deprecate_old_breadcrumbs_configuration(:sentry_logger)
|
2
2
|
|
3
|
-
|
4
|
-
module BreadcrumbLogger
|
5
|
-
LEVELS = {
|
6
|
-
::Logger::DEBUG => 'debug',
|
7
|
-
::Logger::INFO => 'info',
|
8
|
-
::Logger::WARN => 'warn',
|
9
|
-
::Logger::ERROR => 'error',
|
10
|
-
::Logger::FATAL => 'fatal'
|
11
|
-
}.freeze
|
12
|
-
|
13
|
-
EXC_FORMAT = /^([a-zA-Z0-9]+)\:\s(.*)$/
|
14
|
-
|
15
|
-
def self.parse_exception(message)
|
16
|
-
lines = message.split(/\n\s*/)
|
17
|
-
# TODO: wat
|
18
|
-
return nil unless lines.length > 2
|
19
|
-
|
20
|
-
match = lines[0].match(EXC_FORMAT)
|
21
|
-
return nil unless match
|
22
|
-
|
23
|
-
_, type, value = match.to_a
|
24
|
-
[type, value]
|
25
|
-
end
|
26
|
-
|
27
|
-
def add(*args)
|
28
|
-
add_breadcrumb(*args)
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def add_breadcrumb(severity, message = nil, progname = nil)
|
33
|
-
message = progname if message.nil? # see Ruby's Logger docs for why
|
34
|
-
return if ignored_logger?(progname)
|
35
|
-
return if message.nil? || message == ""
|
36
|
-
|
37
|
-
# some loggers will add leading/trailing space as they (incorrectly, mind you)
|
38
|
-
# think of logging as a shortcut to std{out,err}
|
39
|
-
message = message.strip
|
40
|
-
|
41
|
-
last_crumb = Raven.breadcrumbs.peek
|
42
|
-
# try to avoid dupes from logger broadcasts
|
43
|
-
if last_crumb.nil? || last_crumb.message != message
|
44
|
-
error = Raven::BreadcrumbLogger.parse_exception(message)
|
45
|
-
# TODO(dcramer): we need to filter out the "currently captured error"
|
46
|
-
if error
|
47
|
-
Raven.breadcrumbs.record do |crumb|
|
48
|
-
crumb.level = Raven::BreadcrumbLogger::LEVELS.fetch(severity, nil)
|
49
|
-
crumb.category = progname || 'error'
|
50
|
-
crumb.type = 'error'
|
51
|
-
crumb.data = {
|
52
|
-
:type => error[0],
|
53
|
-
:value => error[1]
|
54
|
-
}
|
55
|
-
end
|
56
|
-
else
|
57
|
-
Raven.breadcrumbs.record do |crumb|
|
58
|
-
crumb.level = Raven::BreadcrumbLogger::LEVELS.fetch(severity, nil)
|
59
|
-
crumb.category = progname || 'logger'
|
60
|
-
crumb.message = message
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def ignored_logger?(progname)
|
69
|
-
progname == "sentry" ||
|
70
|
-
Raven.configuration.exclude_loggers.include?(progname)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
module OldBreadcrumbLogger
|
74
|
-
def self.included(base)
|
75
|
-
base.class_eval do
|
76
|
-
include Raven::BreadcrumbLogger
|
77
|
-
alias_method :add_without_raven, :add
|
78
|
-
alias_method :add, :add_with_raven
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_with_raven(*args)
|
83
|
-
add_breadcrumb(*args)
|
84
|
-
add_without_raven(*args)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
Raven.safely_prepend(
|
90
|
-
"BreadcrumbLogger",
|
91
|
-
:from => Raven,
|
92
|
-
:to => ::Logger
|
93
|
-
)
|
3
|
+
require "raven/breadcrumbs/sentry_logger"
|