sentry-raven 0.12.0 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +13 -0
  3. data/.gitmodules +0 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +74 -0
  6. data/.travis.yml +47 -0
  7. data/Gemfile +38 -0
  8. data/LICENSE +1 -1
  9. data/README.md +99 -17
  10. data/Rakefile +30 -0
  11. data/changelog.md +522 -0
  12. data/exe/raven +32 -0
  13. data/lib/raven/backtrace.rb +42 -33
  14. data/lib/raven/base.rb +70 -188
  15. data/lib/raven/breadcrumbs/activesupport.rb +19 -0
  16. data/lib/raven/breadcrumbs/logger.rb +93 -0
  17. data/lib/raven/breadcrumbs.rb +76 -0
  18. data/lib/raven/cli.rb +38 -42
  19. data/lib/raven/client.rb +112 -53
  20. data/lib/raven/configuration.rb +390 -91
  21. data/lib/raven/context.rb +28 -6
  22. data/lib/raven/event.rb +180 -164
  23. data/lib/raven/instance.rb +233 -0
  24. data/lib/raven/integrations/delayed_job.rb +30 -21
  25. data/lib/raven/integrations/rack-timeout.rb +19 -0
  26. data/lib/raven/integrations/rack.rb +139 -0
  27. data/lib/raven/integrations/rails/active_job.rb +61 -0
  28. data/lib/raven/{rails → integrations/rails}/controller_methods.rb +1 -1
  29. data/lib/raven/integrations/rails/controller_transaction.rb +13 -0
  30. data/lib/raven/integrations/rails/overrides/debug_exceptions_catcher.rb +31 -0
  31. data/lib/raven/integrations/rails/overrides/streaming_reporter.rb +23 -0
  32. data/lib/raven/integrations/rails.rb +79 -0
  33. data/lib/raven/integrations/railties.rb +1 -0
  34. data/lib/raven/integrations/rake.rb +18 -0
  35. data/lib/raven/integrations/sidekiq.rb +87 -0
  36. data/lib/raven/{tasks.rb → integrations/tasks.rb} +2 -3
  37. data/lib/raven/interface.rb +25 -0
  38. data/lib/raven/interfaces/exception.rb +5 -12
  39. data/lib/raven/interfaces/http.rb +4 -41
  40. data/lib/raven/interfaces/message.rb +10 -7
  41. data/lib/raven/interfaces/single_exception.rb +14 -0
  42. data/lib/raven/interfaces/stack_trace.rb +43 -29
  43. data/lib/raven/linecache.rb +32 -14
  44. data/lib/raven/logger.rb +13 -16
  45. data/lib/raven/processor/cookies.rb +26 -0
  46. data/lib/raven/processor/http_headers.rb +55 -0
  47. data/lib/raven/processor/post_data.rb +22 -0
  48. data/lib/raven/processor/removecircularreferences.rb +9 -9
  49. data/lib/raven/processor/removestacktrace.rb +16 -3
  50. data/lib/raven/processor/sanitizedata.rb +75 -29
  51. data/lib/raven/processor/utf8conversion.rb +38 -12
  52. data/lib/raven/processor.rb +6 -19
  53. data/lib/raven/transports/dummy.rb +16 -0
  54. data/lib/raven/transports/http.rb +41 -29
  55. data/lib/raven/transports/stdout.rb +20 -0
  56. data/lib/raven/transports.rb +2 -14
  57. data/lib/raven/utils/deep_merge.rb +22 -0
  58. data/lib/raven/utils/exception_cause_chain.rb +19 -0
  59. data/lib/raven/utils/real_ip.rb +62 -0
  60. data/lib/raven/version.rb +3 -1
  61. data/lib/sentry-raven-without-integrations.rb +1 -0
  62. data/sentry-raven.gemspec +21 -0
  63. metadata +49 -90
  64. data/bin/raven +0 -42
  65. data/lib/raven/better_attr_accessor.rb +0 -44
  66. data/lib/raven/error.rb +0 -4
  67. data/lib/raven/interfaces.rb +0 -34
  68. data/lib/raven/okjson.rb +0 -609
  69. data/lib/raven/rack.rb +0 -75
  70. data/lib/raven/rails/middleware/debug_exceptions_catcher.rb +0 -16
  71. data/lib/raven/railtie.rb +0 -38
  72. data/lib/raven/rake.rb +0 -13
  73. data/lib/raven/sidekiq.rb +0 -27
  74. data/lib/raven/transports/udp.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5fbeb1ae8141697af3bf06f4c2167f97af8a7e58
4
- data.tar.gz: 3431f08512c915bce224d07fb8ad77d5f04fe62a
2
+ SHA256:
3
+ metadata.gz: 478a0cd677f1508fc2153381addf6956e189c5f9491ede8f79b6097977dd59b9
4
+ data.tar.gz: d87fe2f303acf7e1d8b658950a1e591800eaf8a0f8bbdd35637355ac6856f571
5
5
  SHA512:
6
- metadata.gz: 869b6bb29a4a351c8694de220ea6513bafea70554488fd1086b3fcced14510cae903621e37c9f86dedab1e12d40da51fb73c138a12a9b460afddba1485f7fd71
7
- data.tar.gz: ef80ba9d906d81621e4add41b76368ee2549c7bbef3053bf9c280f10b8c3808a1cff39019bc20b01d70201f37bdf28585f65f977dcd76d1f9fc0863d005d26cb
6
+ metadata.gz: c83298b6f11a500e50f4e530de5421f32d15f7ea72d3a6aea18cd4330f832073a2000a68228b0237313e709b3e4adba570b140837256798ff3987b9eb0bb0fc9
7
+ data.tar.gz: 80405a6c1d1f99a7b65ed9491bd17c0d4143a5d5f212c6408988c9de329bc2bee2f2c6c1421d6134cc7f3d4c23ed2da06d0ba76509f6ae191f0236e83c53bdf8
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ coverage
2
+ pkg
3
+ ruby/
4
+ log/
5
+ .bundle
6
+ *.gem
7
+ gemfiles/*.lock
8
+ Gemfile.lock
9
+ .coveralls.yml
10
+ .ruby-version
11
+ .ruby-gemset
12
+ .idea
13
+ *.rdb
data/.gitmodules ADDED
File without changes
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.rubocop.yml ADDED
@@ -0,0 +1,74 @@
1
+ AllCops:
2
+ Include:
3
+ - 'lib/**/*.rb'
4
+ - 'spec/**/*.rb'
5
+ Exclude:
6
+ - 'examples/**/*'
7
+ - 'vendor/**/*'
8
+
9
+ Metrics/ClassLength:
10
+ Max: 300
11
+ CountComments: false
12
+
13
+ Metrics/AbcSize:
14
+ Max: 40
15
+
16
+ Metrics/CyclomaticComplexity:
17
+ Max: 12
18
+
19
+ Metrics/PerceivedComplexity:
20
+ Max: 11
21
+
22
+ Metrics/LineLength:
23
+ Max: 155
24
+
25
+ Metrics/MethodLength:
26
+ Max: 30
27
+
28
+ Style/SignalException:
29
+ Enabled: false
30
+
31
+ Performance/Casecmp:
32
+ Enabled: false
33
+
34
+ Style/ClassAndModuleChildren:
35
+ Enabled: false
36
+
37
+ Style/ParallelAssignment:
38
+ Enabled: false
39
+
40
+ Style/Documentation:
41
+ Enabled: false
42
+
43
+ Style/RescueModifier:
44
+ Enabled: false
45
+
46
+ Style/StringLiterals:
47
+ Enabled: false
48
+
49
+ Style/CaseEquality:
50
+ Enabled: false
51
+
52
+ Style/DoubleNegation:
53
+ Enabled: false
54
+
55
+ Style/FileName:
56
+ Exclude:
57
+ - 'lib/sentry-raven-without-integrations.rb'
58
+ - 'lib/sentry-raven.rb'
59
+
60
+ Style/NumericLiterals:
61
+ Exclude:
62
+ - 'spec/raven/processors/sanitizedata_processor_spec.rb'
63
+
64
+ Style/HashSyntax:
65
+ EnforcedStyle: hash_rockets
66
+
67
+ Lint/RescueException:
68
+ Exclude:
69
+ - 'lib/raven/base.rb'
70
+ - 'lib/raven/instance.rb'
71
+ - 'lib/raven/integrations/delayed_job.rb'
72
+ - 'lib/raven/integrations/rack.rb'
73
+ - 'lib/raven/integrations/sidekiq.rb'
74
+ - 'spec/raven/event_spec.rb'
data/.travis.yml ADDED
@@ -0,0 +1,47 @@
1
+ language: ruby
2
+ dist: trusty
3
+ group: beta
4
+ cache: bundler
5
+
6
+ services:
7
+ - redis-server
8
+
9
+ branches:
10
+ only: [master]
11
+
12
+ rvm:
13
+ - 2.2.10
14
+ - 2.3.8
15
+ - 2.4.9
16
+ - 2.5.7
17
+ - 2.6.5
18
+
19
+ env:
20
+ - RAILS_VERSION=4
21
+ - RAILS_VERSION=5
22
+ - RAILS_VERSION=0
23
+
24
+ addons:
25
+ apt:
26
+ packages:
27
+ - haveged
28
+
29
+ before_install:
30
+ - service haveged start
31
+ # Pin bundler version due to https://github.com/rubygems/rubygems/issues/2055
32
+ - gem install bundler -v 1.16.0
33
+
34
+ matrix:
35
+ include:
36
+ - rvm: 1.9
37
+ env: RAILS_VERSION=4
38
+ - rvm: jruby-1.7.27
39
+ env: JRUBY_OPTS="--dev" RAILS_VERSION=4
40
+ - rvm: jruby-9.2.9.0
41
+ env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=4
42
+ - rvm: jruby-9.2.9.0
43
+ env: JRUBY_OPTS="--dev -J-Djruby.launch.inproc=true -J-Xmx1024M" RAILS_VERSION=5
44
+ - rvm: ruby-head
45
+ env: RAILS_VERSION=0
46
+ allow_failures:
47
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,38 @@
1
+ source "https://rubygems.org/"
2
+
3
+ gemspec
4
+
5
+ if ENV["RAILS_VERSION"] && (ENV["RAILS_VERSION"].to_i == 4)
6
+ gem "rails", "< 5"
7
+ gem "rspec-rails", "> 3"
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", "> 3"
13
+ end
14
+
15
+ if RUBY_VERSION < '2.0'
16
+ gem "mime-types", "< 3.0.0"
17
+ gem "nokogiri", "~> 1.6.8"
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"
25
+ end
26
+ gem "pry"
27
+ gem "pry-coolline"
28
+ gem "benchmark-ips"
29
+ gem "benchmark-ipsa" if RUBY_VERSION > '2.0'
30
+ gem "ruby-prof", platform: :mri
31
+ gem "rake", "> 12"
32
+ gem "rubocop", "~> 0.41.1" # Last version that supported 1.9, upgrade to 0.50 after we drop 1.9
33
+ gem "rspec", "> 3"
34
+ gem "capybara" # rspec system tests
35
+ gem "puma" # rspec system tests
36
+
37
+ gem "timecop"
38
+ gem "test-unit", platform: :mri if RUBY_VERSION > '2.2'
data/LICENSE CHANGED
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [yyyy] [name of copyright owner]
189
+ Copyright 2015 Functional Software, Inc
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -1,35 +1,61 @@
1
- # Raven-Ruby
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
+ # Raven-Ruby, the Ruby Client for Sentry
2
9
 
3
10
  [![Gem Version](https://img.shields.io/gem/v/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven)
4
11
  [![Build Status](https://img.shields.io/travis/getsentry/raven-ruby/master.svg)](https://travis-ci.org/getsentry/raven-ruby)
5
- [![Coverage Status](https://img.shields.io/coveralls/getsentry/raven-ruby/master.svg)](https://coveralls.io/r/getsentry/raven-ruby)
12
+ [![Gem](https://img.shields.io/gem/dt/sentry-raven.svg)](https://rubygems.org/gems/sentry-raven/)
13
+ [![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)
14
+
15
+
16
+ [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
6
17
 
7
- A client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
18
+ The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
8
19
 
9
20
  ## Requirements
10
21
 
11
- We test on Ruby MRI 1.8.7/REE, 1.9.3, 2.0 and 2.1. JRuby support is experimental - check TravisCI to see if the build is passing or failing.
22
+ We test on Ruby 1.9, 2.2, 2.3, and 2.4 at the latest patchlevel/teeny version. We also support JRuby 1.7 and 9.0. Our Rails integration works with Rails 4.2+ (including Rails 5).
12
23
 
13
24
  ## Getting Started
25
+
14
26
  ### Install
27
+
15
28
  ```ruby
16
- gem "sentry-raven", :require => 'raven' #, :github => "getsentry/raven-ruby"
29
+ gem "sentry-raven"
17
30
  ```
18
- ### Set SENTRY_DSN
31
+
32
+ ### Raven only runs when SENTRY_DSN is set
33
+
34
+ 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!
35
+
19
36
  ```bash
20
37
  # Set your SENTRY_DSN environment variable.
21
- export SENTRY_DSN=http://public:secret@example.com/project-id
38
+ export SENTRY_DSN=http://public@example.com/project-id
22
39
  ```
23
40
  ```ruby
24
41
  # Or you can configure the client in the code (not recommended - keep your DSN secret!)
25
42
  Raven.configure do |config|
26
- config.dsn = 'http://public:secret@example.com/project-id'
43
+ config.dsn = 'http://public@example.com/project-id'
27
44
  end
28
45
  ```
29
- ### Call
30
- If you use Rails, you're already done - no more configuration required! Check [Integrations](https://github.com/getsentry/raven-ruby/wiki/Integrations) for more details on other gems Sentry integrates with automatically.
46
+
47
+ ### Raven doesn't report some kinds of data by default
48
+
49
+ **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).
50
+
51
+ 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/)
52
+
53
+ ### Usage
54
+
55
+ **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.
31
56
 
32
57
  Otherwise, Raven supports two methods of capturing exceptions:
58
+
33
59
  ```ruby
34
60
  Raven.capture do
35
61
  # capture any exceptions which happen during execution of this block
@@ -43,12 +69,68 @@ rescue ZeroDivisionError => exception
43
69
  end
44
70
  ```
45
71
 
46
- ## More Information
72
+ ### More configuration
73
+
74
+ You're all set - but there's a few more settings you may want to know about too!
75
+
76
+ #### async
77
+
78
+ When an error or message occurs, the notification is immediately sent to Sentry. Raven can be configured to send asynchronously:
79
+
80
+ ```ruby
81
+ config.async = lambda { |event|
82
+ Thread.new { Raven.send_event(event) }
83
+ }
84
+ ```
85
+
86
+ Using a thread to send events will be adequate for truly parallel Ruby platforms such as JRuby, though the benefit on MRI/CRuby will be limited. If the async callback raises an exception, Raven will attempt to send synchronously.
47
87
 
48
- Full documentation and more information on advanced configuration, sending more information, scrubbing sensitive data, and more can be found on [the wiki](https://github.com/getsentry/raven-ruby/wiki).
88
+ Note that the naive example implementation has a major drawback - it can create an infinite number of threads. We recommend creating a background job, using your background job processor, that will send Sentry notifications in the background.
89
+
90
+ ```ruby
91
+ config.async = lambda { |event| SentryJob.perform_later(event) }
92
+
93
+ class SentryJob < ActiveJob::Base
94
+ queue_as :default
95
+
96
+ def perform(event)
97
+ Raven.send_event(event)
98
+ end
99
+ end
100
+ ```
101
+
102
+ #### transport_failure_callback
103
+
104
+ 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.
105
+
106
+ ```ruby
107
+ config.transport_failure_callback = lambda { |event|
108
+ AdminMailer.email_admins("Oh god, it's on fire!", event).deliver_later
109
+ }
110
+ ```
111
+
112
+ #### Context
113
+
114
+ 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.
115
+
116
+ There are three primary methods for providing request context:
117
+
118
+ ```ruby
119
+ # bind the logged in user
120
+ Raven.user_context email: 'foo@example.com'
121
+
122
+ # tag the request with something interesting
123
+ Raven.tags_context interesting: 'yes'
124
+
125
+ # provide a bit of additional context
126
+ Raven.extra_context happiness: 'very'
127
+ ```
128
+
129
+ For more information, see [Context](https://docs.sentry.io/clients/ruby/context/).
130
+
131
+ ## More Information
49
132
 
50
- * [Documentation](https://github.com/getsentry/raven-ruby/wiki)
51
- * [Bug Tracker](http://github.com/getsentry/raven-ruby/issues>)
52
- * [Code](http://github.com/getsentry/raven-ruby>)
53
- * [Mailing List](https://groups.google.com/group/getsentry>)
54
- * [IRC](irc://irc.freenode.net/sentry>) (irc.freenode.net, #sentry)
133
+ * [Documentation](https://docs.sentry.io/clients/ruby/)
134
+ * [Bug Tracker](https://github.com/getsentry/raven-ruby/issues)
135
+ * [Forum](https://forum.sentry.io/)
136
+ - [Discord](https://discord.gg/ez5KZN7)
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'rake'
2
+ require 'raven'
3
+ require 'rubygems/package_task'
4
+ require 'bundler/gem_tasks'
5
+
6
+ gemspec = Gem::Specification.load(Dir['*.gemspec'].first)
7
+
8
+ Gem::PackageTask.new(gemspec).define
9
+
10
+ begin
11
+ require 'rubygems'
12
+ require 'rspec/core/rake_task'
13
+
14
+ require 'rubocop/rake_task'
15
+ RuboCop::RakeTask.new(:rubocop) do |task|
16
+ task.patterns = ['lib/**/*.rb','spec/**/*.rb',]
17
+ task.options << '--display-cop-names'
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:spec) do |spec|
21
+ spec.pattern = 'spec/**/*_spec.rb'
22
+ end
23
+
24
+ rescue LoadError
25
+ task :spec do
26
+ abort "Rspec is not available. bundle install to run unit tests"
27
+ end
28
+ end
29
+
30
+ task :default => [:rubocop, :spec]