sentry-raven 3.0.2 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.craft.yml +9 -5
  3. data/.scripts/bump-version.rb +5 -0
  4. data/{changelog.md → CHANGELOG.md} +165 -8
  5. data/Gemfile +10 -3
  6. data/Makefile +3 -0
  7. data/README.md +42 -15
  8. data/lib/raven/backtrace.rb +2 -0
  9. data/lib/raven/base.rb +3 -0
  10. data/lib/raven/breadcrumbs/active_support_logger.rb +25 -0
  11. data/lib/raven/breadcrumbs/logger.rb +2 -92
  12. data/lib/raven/breadcrumbs/sentry_logger.rb +73 -0
  13. data/lib/raven/cli.rb +8 -19
  14. data/lib/raven/client.rb +1 -1
  15. data/lib/raven/configuration.rb +80 -5
  16. data/lib/raven/context.rb +13 -8
  17. data/lib/raven/core_ext/object/deep_dup.rb +57 -0
  18. data/lib/raven/core_ext/object/duplicable.rb +153 -0
  19. data/lib/raven/event.rb +27 -13
  20. data/lib/raven/helpers/deprecation_helper.rb +17 -0
  21. data/lib/raven/instance.rb +17 -2
  22. data/lib/raven/integrations/delayed_job.rb +2 -1
  23. data/lib/raven/integrations/rack-timeout.rb +5 -1
  24. data/lib/raven/integrations/rack.rb +5 -4
  25. data/lib/raven/integrations/rails.rb +12 -3
  26. data/lib/raven/integrations/rails/active_job.rb +2 -1
  27. data/lib/raven/integrations/rails/backtrace_cleaner.rb +29 -0
  28. data/lib/raven/integrations/sidekiq.rb +4 -78
  29. data/lib/raven/integrations/sidekiq/cleanup_middleware.rb +13 -0
  30. data/lib/raven/integrations/sidekiq/error_handler.rb +38 -0
  31. data/lib/raven/processor/cookies.rb +1 -1
  32. data/lib/raven/processor/removecircularreferences.rb +2 -1
  33. data/lib/raven/transports/http.rb +2 -3
  34. data/lib/raven/utils/context_filter.rb +42 -0
  35. data/lib/raven/utils/request_id.rb +16 -0
  36. data/lib/raven/version.rb +1 -1
  37. data/lib/sentry-raven-without-integrations.rb +6 -1
  38. data/lib/sentry_raven_without_integrations.rb +1 -0
  39. data/sentry-raven.gemspec +7 -0
  40. metadata +21 -11
  41. data/.github/workflows/test.yml +0 -77
  42. data/.gitignore +0 -15
  43. data/.gitmodules +0 -0
  44. data/.rspec +0 -1
  45. data/.rubocop.yml +0 -109
  46. data/.scripts/bump-version.sh +0 -9
  47. data/lib/raven/breadcrumbs/activesupport.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 766dba6870e025b98287e3d2ecf7a2f14aad5c37169e4ffc99bd5c740f30a7eb
4
- data.tar.gz: c1b0c1abf8218d480f40e7cd3653b30d4747a5a2c47111a20f269cac219e091c
3
+ metadata.gz: 8c836de333d5f6013b562a5d189b6e775ca61965c7070a111b61d37402d318d1
4
+ data.tar.gz: b1923aeea7733a7e0d51fdc6e2f49b7dd046b5eaaba1067507229d0cc5262352
5
5
  SHA512:
6
- metadata.gz: 07ef24c7e92460508209ca9fc1d76d09bd317f7a40d693256f1b44afe9e476f1d6f271db3557b848070c15b7c9277c3cff450ebf3882b206d25419eedbd65327
7
- data.tar.gz: ef792fc072cb8c5e2247d868358c413e64dfedddf2f2232c3d81f66a87d700aa22eb3f6f8563b8df83970d20330b029ce8da299a2bd1cf98f458383ba89fa392
6
+ metadata.gz: 7ae04b49b38a134386b44e04675f47bbf9742ba1b39f84ac0c51a87b3852380c1b60d91a7a7c67e208a9415c75880559941ac343cb3378a8129259b4aeb63984
7
+ data.tar.gz: 0fd029cf50d3a54f98906cee4f1c4177282f91030239f093d53e3949bc37a533fd4557f6f932e5c22051416e92ff28a53da7fbc2a9086c83181538f8c81d6c83
data/.craft.yml CHANGED
@@ -1,14 +1,18 @@
1
- minVersion: '0.9.0'
1
+ minVersion: '0.13.2'
2
2
  github:
3
3
  owner: getsentry
4
- repo: raven-ruby
4
+ repo: sentry-ruby
5
5
  changelogPolicy: simple
6
- preReleaseCommand: ruby .scripts/bump-version.sh
7
- statusProvider:
8
- name: github
6
+ preReleaseCommand: ruby .scripts/bump-version.rb
7
+ releaseBranchPrefix: release-sentry-raven
8
+ statusProvider:
9
+ name: github
10
+ artifactProvider:
11
+ name: github
9
12
  targets:
10
13
  - name: gem
11
14
  - name: github
15
+ tagPrefix: sentry-raven-v
12
16
  - name: registry
13
17
  type: sdk
14
18
  config:
@@ -0,0 +1,5 @@
1
+ file_name = "lib/raven/version.rb"
2
+
3
+ text = File.read(file_name)
4
+ new_contents = text.gsub(/VERSION = ".*"/, "VERSION = \"#{ARGV[1]}\"")
5
+ File.open(file_name, "w") {|file| file.puts new_contents }
@@ -1,18 +1,175 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 3.1.2
4
+
5
+ - Fix Delayed::Plugins::Raven when job raises exception [#1057](https://github.com/getsentry/sentry-ruby/pull/1057)
6
+ - Merge hash instead of replacing the original value in user_context [#1064](https://github.com/getsentry/sentry-ruby/pull/1064)
7
+ - Don't exclude ActionView::MissingTemplate error by default [#1092](https://github.com/getsentry/sentry-ruby/pull/1092)
8
+ - Fix typo: much -> must for Raven::Event [#1106](https://github.com/getsentry/sentry-ruby/pull/1106)
9
+ - Fix undefined local variable or method logger [#1143](https://github.com/getsentry/sentry-ruby/pull/1143)
10
+ - Fixes [#1110](https://github.com/getsentry/sentry-ruby/issues/1110)
11
+ - fix format headers for sentry-raven [#1198](https://github.com/getsentry/sentry-ruby/pull/1198)
12
+ - Print deprecation message after sentry-raven is installed [#1206](https://github.com/getsentry/sentry-ruby/pull/1206)
13
+
14
+ ## 3.1.1
15
+
16
+ **Feature**
17
+
18
+ - Add request id to headers if exists ([#1033](https://github.com/getsentry/sentry-ruby/pull/1033))
19
+
20
+ - Allow blocks on user_context ([#1023](https://github.com/getsentry/sentry-ruby/pull/1023))
21
+
22
+ - Enable configurable rack environment recorded parameters ([#860](https://github.com/getsentry/sentry-ruby/pull/860))
23
+
24
+ - Remove ActiveJob keys for both Sidekiq and DelayedJob ([#898](https://github.com/getsentry/sentry-ruby/pull/898))
25
+
26
+ **Fix**
27
+
28
+ - Remove circular dependency in transport/http.rb ([#1035](https://github.com/getsentry/sentry-ruby/pull/1035))
29
+
30
+ ## 3.1.0
31
+
32
+ **Feature**
33
+
34
+ - Exclude all 4xx Rails errors ([#1004](https://github.com/getsentry/raven-ruby/pull/1004))
35
+
36
+ See the full list [here](https://github.com/getsentry/raven-ruby/blob/master/lib/raven/configuration.rb#L198-L219)
37
+
38
+ - Add some error context in `transport_failure_callback` ([#1003](https://github.com/getsentry/raven-ruby/pull/1003))
39
+
40
+ Before:
41
+
42
+ ```ruby
43
+ config.transport_failure_callback = lambda { |event|
44
+ AdminMailer.email_admins("Oh god, it's on fire!", event).deliver_later
45
+ }
46
+ ```
47
+
48
+ After:
49
+
50
+ ```ruby
51
+ config.transport_failure_callback = lambda { |event, error|
52
+ AdminMailer.email_admins("Oh god, it's on fire because #{error.message}!", event).deliver_later
53
+ }
54
+ ```
55
+
56
+ - Support cleaning up exception backtrace with customized backtrace_cleaner ([#1011](https://github.com/getsentry/raven-ruby/pull/1011))
57
+
58
+ The new config `backtrace_cleanup_callback` takes a lambda/proc object (default is `nil`) and will be called with exception's backtrace
59
+
60
+ ```ruby
61
+ Raven.configure do |config|
62
+ config.backtrace_cleanup_callback = lambda do |backtrace|
63
+ Rails.backtrace_cleaner.clean(backtrace)
64
+ end
65
+ end
66
+ ```
67
+
68
+ And with the Rails integration, it'll automatically use a customized `Raven::Rails::BacktraceCleaner` to clean up exception's backtrace. It's basically Rails 6's [backtrace cleaner](https://github.com/rails/rails/blob/master/railties/lib/rails/backtrace_cleaner.rb) but without silencers.
69
+
70
+ The main reason to add this cleaner is to remove template methods from the trace, e.g.
71
+
72
+ ```
73
+ app/views/welcome/view_error.html.erb in _app_views_welcome_view_error_html_erb__2807287320172182514_65600 at line 1
74
+ ```
75
+
76
+ will become
77
+
78
+ ```
79
+ app/views/welcome/view_error.html.erb at line 1
80
+ ```
81
+
82
+ This can help Sentry group issues more accurately. See [#957](https://github.com/getsentry/raven-ruby/issues/957) for more information about this.
83
+
84
+ If you don't want this change, you can disable it with:
85
+
86
+ ```ruby
87
+ Raven.configure do |config|
88
+ config.backtrace_cleanup_callback = nil
89
+ end
90
+ ```
91
+
92
+
93
+ - Make dsn value accessable from config ([#1012](https://github.com/getsentry/raven-ruby/pull/1012))
94
+
95
+ You can now access the dsn value via `Raven.configuration.dsn`
96
+
97
+ **Deprecation**
98
+
99
+ - Deprecate dasherized filenames ([#1006](https://github.com/getsentry/raven-ruby/pull/1006))
100
+
101
+ If you're using
102
+
103
+ ```ruby
104
+ gem 'sentry-raven', require: 'sentry-raven-without-integrations'
105
+ # or
106
+ require "sentry-raven-without-integrations"
107
+ ```
108
+
109
+ you will start seeing deprecation warnings. Please change them into
110
+
111
+ ```ruby
112
+ gem 'sentry-raven', require: 'sentry_raven_without_integrations'
113
+ # or
114
+ require "sentry_raven_without_integrations"
115
+ ```
116
+
117
+ - Unify breadcrumb loggers activation ([#1016](https://github.com/getsentry/raven-ruby/pull/1016))
118
+
119
+ Currently, we activate our breadcrumb loggers differently:
120
+
121
+ ```ruby
122
+ require "raven/breadcrumbs/sentry_logger"
123
+ Raven.configuration.rails_activesupport_breadcrumbs = true
124
+ ```
125
+
126
+ It's not a nice user interface, so this PR adds a new configuration
127
+ option `breadcrumbs_logger` to improve this:
128
+
129
+ ```ruby
130
+ Raven.configuration.breadcrumbs_logger = :sentry_logger
131
+ Raven.configuration.breadcrumbs_logger = :active_support_logger
132
+ Raven.configuration.breadcrumbs_logger = [:sentry_logger, :active_support_logger]
133
+ ```
134
+
135
+ Please migrate to the new activation apporach, otherwise you'll see depraction warnings. And old ones will be dropped in version 4.0.
136
+
137
+ **Refactor**
138
+
139
+ - Accept non-string message in Event.from_exception ([#1005](https://github.com/getsentry/raven-ruby/pull/1005))
140
+ - Refactor event initialization ([#1010](https://github.com/getsentry/raven-ruby/pull/1010))
141
+ - Refactor sidekiq integration ([#1019](https://github.com/getsentry/raven-ruby/pull/1019))
142
+
143
+ **Fix**
144
+
145
+ - Replace sys_command usages in context.rb ([#1017](https://github.com/getsentry/raven-ruby/pull/1017))
146
+ - Fix merge error from rack-timeout raven_context on old releases ([#1007](https://github.com/getsentry/raven-ruby/pull/1007))
147
+ - Return value of `rescue_with_handler` when intercepting ActiveJob exceptions ([#1027](https://github.com/getsentry/raven-ruby/pull/1027))
148
+
149
+ ## 3.0.4
150
+
151
+ - fix: Don't log warning messages when it doesn't need to (#1000)
152
+ - fix: Revert "Refactor Raven::Client class" (#1002)
153
+
154
+ ## 3.0.3
155
+
156
+ - fix: Ensure Processor::Cookie can run after Processor::RemoveCircularReferences (#996)
157
+ - fix: Avoid mutating user passed in options (#994)
158
+ - fix: Fix/Refactor Raven::Cli (#989)
159
+ - ref: Refactor Raven::Client class (#995)
160
+ - It adds `Event#message_from_exception` and `Event#log_message` interfaces
4
161
 
5
162
  ## 3.0.2
6
163
 
7
- * fix: Add gem target for craft
164
+ - fix: Add gem target for craft
8
165
 
9
166
  ## 3.0.1
10
167
 
11
- * fix: Improve SanitizeData processor (#984)
12
- * fix: Masking cookies as key/pair instead of a single string (#983)
13
- * fix: Transports classes' requiring issue (#986)
14
- * fix: Frozen string issues (#977)
15
- * feat: Officially support Rails 6 (#982)
168
+ - fix: Improve SanitizeData processor (#984)
169
+ - fix: Masking cookies as key/pair instead of a single string (#983)
170
+ - fix: Transports classes' requiring issue (#986)
171
+ - fix: Frozen string issues (#977)
172
+ - feat: Officially support Rails 6 (#982)
16
173
 
17
174
  3.0.0
18
175
  ----
@@ -499,7 +656,7 @@ OTHER CHANGES:
499
656
  0.12.0
500
657
  ------
501
658
 
502
- - You can now give additional fields to the SanitizeData processor. Values matched are replaced by the string mask (*********). Full documentation (and how to use with Rails config.filter_parameters) [here](https://docs.getsentry.com/hosted/clients/ruby/config/). [jamescway, #232]
659
+ - You can now give additional fields to the SanitizeData processor. Values matched are replaced by the string mask (*********). Full documentation (and how to use with Rails config.filter_parameters) [here](https://docs.sentry.io/platforms/ruby/config/). [jamescway, #232]
503
660
  - An additional processor has been added, though it isn't turned on by default: RemoveStacktrace. Use it to remove stacktraces from exception reports. [nateberkopec, #233]
504
661
  - Dependency on `uuidtools` has been removed. [nateberkopec, #231]
505
662
 
data/Gemfile CHANGED
@@ -2,21 +2,28 @@ source "https://rubygems.org/"
2
2
 
3
3
  gemspec
4
4
 
5
- rails_version = ENV["RAILS_VERSION"].to_f
5
+ rails_version = ENV["RAILS_VERSION"]
6
+ rails_version = "5.2" if rails_version.nil?
6
7
 
7
- if rails_version != 0
8
+ if rails_version.to_f != 0
8
9
  gem "rails", "~> #{rails_version}"
9
10
  gem "rspec-rails", "~> 4.0"
10
11
  end
11
12
 
13
+ gem "delayed_job"
12
14
  gem "sidekiq"
13
15
 
14
16
  gem "rack"
15
17
  gem "rack-timeout"
16
18
 
19
+ # TODO: Remove this if https://github.com/jruby/jruby/issues/6547 is addressed
20
+ gem "i18n", "<= 1.8.7"
21
+
17
22
  gem "pry"
18
23
  gem "benchmark-ips"
24
+ gem "benchmark_driver"
19
25
  gem "benchmark-ipsa"
26
+ gem "benchmark-memory"
20
27
  gem "ruby-prof", platform: :mri
21
28
  gem "rake", "> 12"
22
29
  gem "rubocop", "~> 0.81.0"
@@ -27,4 +34,4 @@ gem "puma" # rspec system tests
27
34
  gem "timecop"
28
35
  gem "test-unit"
29
36
  gem "simplecov"
30
- gem "codecov"
37
+ gem "codecov", "<= 0.2.12"
data/Makefile ADDED
@@ -0,0 +1,3 @@
1
+ build:
2
+ bundle install
3
+ gem build sentry-raven.gemspec
data/README.md CHANGED
@@ -7,9 +7,26 @@
7
7
 
8
8
  # Raven-Ruby, the Ruby Client for Sentry
9
9
 
10
+ ### 🚧 Migrating To The New SDK 🚧
11
+
12
+ We've released our new Ruby SDK, [sentry-ruby](https://github.com/getsentry/sentry-ruby/tree/master/sentry-ruby). Here are the benefits of migrating to it:
13
+
14
+ - **Unified Interfaces With Other SDKs:** The design of `sentry-raven` is outdated compared with our modern Sentry SDKs. If you also use other Sentry SDKs, such as Sentry's JavaScript SDK for your frontend application, you'll notice that their interfaces are quite different from the one provided for `sentry-raven`. The new `sentry-ruby` SDK provides a more consistent user experience across all different platforms.
15
+
16
+ - **Performance Monitoring:** The Sentry Ruby SDK includes [performance monitoring](https://docs.sentry.io/product/performance/), which you can enable if you haven't already as ([discussed here](https://docs.sentry.io/platforms/ruby/performance/)).
17
+
18
+ - **Future Support:** `sentry-raven` has entered maintenance mode, which means it won't receive any new feature supports or aggressive bug fixes.
19
+
20
+ - **Better Extensibility:** Unlike `sentry-raven`, `sentry-ruby` is built with extensibility in mind and will allow the community to build extensions for different integrations/features.
21
+
22
+ If you're interested in the migration, please also read our [migration guide](https://docs.sentry.io/platforms/ruby/migration/) for more information.
23
+
24
+ ---
25
+
26
+
10
27
  [![Gem Version](https://img.shields.io/gem/v/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven)
11
28
  ![Build Status](https://github.com/getsentry/raven-ruby/workflows/Test/badge.svg)
12
- [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/raven-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/raven-ruby/branch/master)
29
+ [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
13
30
  [![Gem](https://img.shields.io/gem/dt/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven/)
14
31
  [![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)
15
32
 
@@ -18,6 +35,7 @@
18
35
 
19
36
  The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
20
37
 
38
+
21
39
  ## Requirements
22
40
 
23
41
  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.
@@ -30,7 +48,7 @@ We test on Ruby 2.3, 2.4, 2.5, 2.6 and 2.7 at the latest patchlevel/teeny versio
30
48
  gem "sentry-raven"
31
49
  ```
32
50
 
33
- ### Raven only runs when SENTRY_DSN is set
51
+ ### Raven only runs when Sentry DSN is set
34
52
 
35
53
  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!
36
54
 
@@ -39,7 +57,7 @@ Raven will capture and send exceptions to the Sentry server whenever its DSN is
39
57
  export SENTRY_DSN=http://public@example.com/project-id
40
58
  ```
41
59
  ```ruby
42
- # Or you can configure the client in the code (not recommended - keep your DSN secret!)
60
+ # Or you can configure the client in the code.
43
61
  Raven.configure do |config|
44
62
  config.dsn = 'http://public@example.com/project-id'
45
63
  end
@@ -49,11 +67,11 @@ end
49
67
 
50
68
  **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).
51
69
 
52
- 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.getsentry.com/hosted/clients/ruby/config/)
70
+ 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/configuration/options/)
53
71
 
54
72
  ### Usage
55
73
 
56
- **If you use Rails, you're already done - no more configuration required!** Check [Integrations](https://docs.getsentry.com/hosted/clients/ruby/integrations/) for more details on other gems Sentry integrates with automatically.
74
+ **If you use Rails, you're already done - no more configuration required!** Check [Integrations](https://docs.sentry.io/platforms/ruby/configuration/integrations/) for more details on other gems Sentry integrates with automatically.
57
75
 
58
76
  Otherwise, Raven supports two methods of capturing exceptions:
59
77
 
@@ -105,29 +123,38 @@ end
105
123
  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.
106
124
 
107
125
  ```ruby
108
- config.transport_failure_callback = lambda { |event|
109
- AdminMailer.email_admins("Oh god, it's on fire!", event).deliver_later
126
+ config.transport_failure_callback = lambda { |event, error|
127
+ AdminMailer.email_admins("Oh god, it's on fire because #{error.message}!", event).deliver_later
110
128
  }
111
129
  ```
112
130
 
113
131
  #### Context
114
132
 
115
- 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.
116
-
117
- There are three primary methods for providing request context:
133
+ 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:
118
134
 
119
135
  ```ruby
120
- # bind the logged in user
121
136
  Raven.user_context email: 'foo@example.com'
122
137
 
123
- # tag the request with something interesting
124
138
  Raven.tags_context interesting: 'yes'
125
139
 
126
- # provide a bit of additional context
127
- Raven.extra_context happiness: 'very'
140
+ Raven.extra_context additional_info: 'foo'
141
+ ```
142
+
143
+ You can also use `tags_context` and `extra_context` to provide scoped information:
144
+
145
+ ```ruby
146
+ Raven.tags_context(interesting: 'yes') do
147
+ # the `interesting: 'yes'` tag will only present in the requests sent inside the block
148
+ Raven.capture_exception(exception)
149
+ end
150
+
151
+ Raven.extra_context(additional_info: 'foo') do
152
+ # same as above, the `additional_info` will only present in this request
153
+ Raven.capture_exception(exception)
154
+ end
128
155
  ```
129
156
 
130
- For more information, see [Context](https://docs.sentry.io/clients/ruby/context/).
157
+ For more information, see [Context](https://docs.sentry.io/platforms/ruby/enriching-events/context/).
131
158
 
132
159
  ## More Information
133
160
 
@@ -94,6 +94,8 @@ module Raven
94
94
  def self.parse(backtrace, opts = {})
95
95
  ruby_lines = backtrace.is_a?(Array) ? backtrace : backtrace.split(/\n\s*/)
96
96
 
97
+ ruby_lines = opts[:configuration].backtrace_cleanup_callback.call(ruby_lines) if opts[:configuration]&.backtrace_cleanup_callback
98
+
97
99
  filters = opts[:filters] || []
98
100
  filtered_lines = ruby_lines.to_a.map do |line|
99
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/request_id'
26
29
  require 'raven/utils/exception_cause_chain'
27
30
  require 'raven/instance'
28
31
 
@@ -0,0 +1,25 @@
1
+ module Raven
2
+ module Breadcrumbs
3
+ module ActiveSupportLogger
4
+ class << self
5
+ def add(name, started, _finished, _unique_id, data)
6
+ Raven.breadcrumbs.record do |crumb|
7
+ crumb.data = data
8
+ crumb.category = name
9
+ crumb.timestamp = started.to_i
10
+ end
11
+ end
12
+
13
+ def inject
14
+ @subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
15
+ add(name, started, finished, unique_id, data)
16
+ end
17
+ end
18
+
19
+ def detach
20
+ ::ActiveSupport::Notifications.unsubscribe(@subscriber)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,93 +1,3 @@
1
- require 'logger'
1
+ DeprecationHelper.deprecate_old_breadcrumbs_configuration(:sentry_logger)
2
2
 
3
- module Raven
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(.*)$/.freeze
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.to_s.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"