sentry-raven 2.7.4 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,141 +0,0 @@
1
- Context
2
- =======
3
-
4
- Additional context can be passed to the capture methods. This allows you
5
- to record extra information that could help you identify the root cause of
6
- the issue or who the error happened for.
7
-
8
- .. sourcecode:: ruby
9
-
10
- Raven.capture_message 'My Event!',
11
- logger: 'logger',
12
- extra: {
13
- my_custom_variable: 'value'
14
- },
15
- tags: {
16
- foo: 'bar'
17
- }
18
-
19
- The following attributes are available:
20
-
21
- * ``logger``: the logger name to record this event under
22
- * ``level``: a string representing the level of this event (fatal, error,
23
- warning, info, debug)
24
- * ``server_name``: the hostname of the server
25
- * ``tags``: a mapping of tags describing this event
26
- * ``extra``: a mapping of arbitrary context
27
- * ``user``: a mapping of user context
28
- * ``transaction``: An array of strings. The final element in the array represents the current transaction, e.g. "HelloController#hello_world" for a Rails controller.
29
-
30
- Providing Request Context
31
- -------------------------
32
-
33
- Most of the time you're not actually calling out to Raven directly, but
34
- you still want to provide some additional context. This lifecycle
35
- generally constists of something like the following:
36
-
37
- * Set some context via a middleware (e.g. the logged in user)
38
- * Send all given context with any events during the request lifecycle
39
- * Cleanup context
40
-
41
- There are three primary methods for providing request context.
42
-
43
- User Context
44
- ~~~~~~~~~~~~
45
-
46
- User context describes the current actor.
47
-
48
- .. sourcecode:: ruby
49
-
50
- # bind the logged in user
51
- Raven.user_context(
52
- # a unique ID which represents this user
53
- id: current_user.id, # 1
54
-
55
- # the actor's email address, if available
56
- email: current_user.email, # "example@example.org"
57
-
58
- # the actor's username, if available
59
- username: current_user.username, # "foo"
60
-
61
- # the actor's IP address, if available
62
- ip_address: request.ip # '127.0.0.1'
63
- )
64
-
65
- When dealing with anonymous users you will still want to send basic user context to ensure Sentry can count them against the unique users:
66
-
67
- .. sourcecode:: ruby
68
-
69
- Raven.user_context(
70
- # the actor's IP address, if available
71
- ip_address: request.ip # '127.0.0.1'
72
- )
73
-
74
- Tags
75
- ~~~~
76
-
77
- You can provide a set of key/value pairs called tags which Sentry will index and aggregate. This will help you understand the distribution of issues, as well as enabling easy lookup via search.
78
-
79
- .. sourcecode:: ruby
80
-
81
- # tag the request with something interesting
82
- Raven.tags_context(
83
- language: I18n.locale, # "en-us"
84
- timezone: current_user.time_zone # "PST"
85
- )
86
-
87
-
88
- Additional Context
89
- ~~~~~~~~~~~~~~~~~~
90
-
91
- In addition to the supported structured data of Sentry, you can provide additional context. This is a key/value mapping, where the values must be JSON compatible, but can be of a rich datatype.
92
-
93
- .. sourcecode:: ruby
94
-
95
- # provide a bit of additional context
96
- Raven.extra_context(
97
- happiness: 'very',
98
- emoji: ['much']
99
- )
100
-
101
- Rack (HTTP) Context
102
- ~~~~~~~~~~~~~~~~~~~
103
-
104
- Additionally, if you're using Rack (without the middleware), you can
105
- easily provide context with the ``rack_context`` helper:
106
-
107
- .. sourcecode:: ruby
108
-
109
- Raven.rack_context(env)
110
-
111
- If you're using the Rack middleware, we've already taken care of cleanup
112
- for you, otherwise you'll need to ensure you perform it manually:
113
-
114
- .. sourcecode:: ruby
115
-
116
- Raven::Context.clear!
117
-
118
- Note: the rack and user context will perform a set operation, whereas tags
119
- and extra context will merge with any existing request context.
120
-
121
- Transactions
122
- ~~~~~~~~~~~~
123
-
124
- The "transaction" is intended to represent the action the event occurred during.
125
- In Rack, this will be the request URL. In Rails, it's the controller name and
126
- action ("HelloController#hello_world").
127
-
128
- Transactions are modeled as a stack. The top item in the stack (i.e. the last
129
- element of the array) will be used as the ``transaction`` for any events:
130
-
131
- .. sourcecode:: ruby
132
-
133
- Raven.context.transaction.push "User Import"
134
- # import some users
135
- Raven.context.transaction.pop
136
-
137
- Transactions may also be overridden/set explicitly during event creation:
138
-
139
- .. sourcecode:: ruby
140
-
141
- Raven.capture_exception(exception, transaction: "User Import")
@@ -1,113 +0,0 @@
1
- .. sentry:edition:: self
2
-
3
- Raven Ruby
4
- ==========
5
-
6
- .. sentry:edition:: hosted, on-premise
7
-
8
- .. class:: platform-ruby
9
-
10
- Ruby
11
- ====
12
-
13
- Raven for Ruby is a client and integration layer for the Sentry error
14
- reporting API. It supports Ruby 1.9.3 and 2.x.
15
- JRuby support is provided but experimental.
16
-
17
- Installation
18
- ------------
19
-
20
- Raven Ruby comes as a gem and is straightforward to install. If you are
21
- using Bundler just add this to your ``Gemfile``:
22
-
23
- .. sourcecode:: ruby
24
-
25
- gem "sentry-raven"
26
-
27
- For other means of installation see :doc:`install`.
28
-
29
- Configuration
30
- -------------
31
-
32
- To use Raven Ruby all you need is your DSN. Like most Sentry libraries it
33
- will honor the ``SENTRY_DSN`` environment variable. You can find it on
34
- the project settings page under API Keys. You can either export it as
35
- environment variable or manually configure it with ``Raven.configure``:
36
-
37
- .. sourcecode:: ruby
38
-
39
- Raven.configure do |config|
40
- config.dsn = '___DSN___'
41
- end
42
-
43
- Reporting Failures
44
- ------------------
45
-
46
- If you use Rails, Rake, Sidekiq, etc, you're already done - no more
47
- configuration required! Check :doc:`integrations/index` for more details on
48
- other gems Sentry integrates with automatically.
49
-
50
- Rack requires a little more setup: :doc:`integrations/rack`
51
-
52
- Otherwise, Raven supports two methods of capturing exceptions:
53
-
54
- .. sourcecode:: ruby
55
-
56
- Raven.capture do
57
- # capture any exceptions which happen during execution of this block
58
- 1 / 0
59
- end
60
-
61
- begin
62
- 1 / 0
63
- rescue ZeroDivisionError => exception
64
- Raven.capture_exception(exception)
65
- end
66
-
67
- Additional Context
68
- ------------------
69
-
70
- Much of the usefulness of Sentry comes from additional context data with
71
- the events. Raven Ruby makes this very convenient by providing
72
- methods to set thread local context data that is then submitted
73
- automatically with all events.
74
-
75
- There are three primary methods for providing request context:
76
-
77
- .. sourcecode:: ruby
78
-
79
- # bind the logged in user
80
- Raven.user_context email: 'foo@example.com'
81
-
82
- # tag the request with something interesting
83
- Raven.tags_context interesting: 'yes'
84
-
85
- # provide a bit of additional context
86
- Raven.extra_context happiness: 'very'
87
-
88
- For more information see :doc:`context`.
89
-
90
- Deep Dive
91
- ---------
92
-
93
- Want to know more? We have a detailed documentation about all parts of
94
- the library and the client integrations.
95
-
96
-
97
- .. toctree::
98
- :maxdepth: 2
99
- :titlesonly:
100
-
101
- install
102
- config
103
- usage
104
-
105
- breadcrumbs
106
- context
107
- processors
108
- integrations/index
109
-
110
- Resources:
111
-
112
- * `Bug Tracker <http://github.com/getsentry/raven-ruby/issues>`_
113
- * `Github Project <http://github.com/getsentry/raven-ruby>`_
@@ -1,40 +0,0 @@
1
- Installation
2
- ============
3
-
4
- Raven Ruby comes as a gem and is straightforward to install. If you are
5
- using Bundler just add this to your ``Gemfile``:
6
-
7
- .. sourcecode:: ruby
8
-
9
- gem "sentry-raven"
10
-
11
- Development Version
12
- -------------------
13
-
14
- If you want to install the development version from github:
15
-
16
- .. sourcecode:: ruby
17
-
18
- gem "sentry-raven", :github => "getsentry/raven-ruby"
19
-
20
- Without Integrations
21
- --------------------
22
-
23
- If you wish to activate integrations manually (or don't want them
24
- activated by default), require "raven/base" instead of "raven" or
25
- "sentry-raven". In that case disable the requiring in the ``Gemfile``:
26
-
27
- .. sourcecode:: ruby
28
-
29
- gem "sentry-raven", :require => false
30
-
31
- And in your initialization code:
32
-
33
- .. sourcecode:: ruby
34
-
35
- require "raven/base"
36
- require "raven/integrations/rails"
37
- require "raven/integrations/delayed_job"
38
-
39
- This stops you from calling ``Raven.inject``, which is where all this
40
- integration loading occurs.
@@ -1,11 +0,0 @@
1
- Heroku
2
- ======
3
-
4
- Installation
5
- ------------
6
-
7
- Enable the ``runtime-dyno-metadata`` Heroku Labs feature in order to enable automated release detection:
8
-
9
- ::
10
-
11
- heroku labs:enable runtime-dyno-metadata -a myapp
@@ -1,59 +0,0 @@
1
- Integrations
2
- ============
3
-
4
- For common environments and frameworks like Rails, Rake, Rack and others
5
- Ruby Raven provides automatic integration for reporting. Most of the time
6
- you don't need to change anything, although you can configure those
7
- features if you want.
8
-
9
- .. toctree::
10
- :maxdepth: 1
11
-
12
- rails
13
- rack
14
- puma
15
- heroku
16
-
17
- The following integrations are available:
18
-
19
- * Sidekiq (``:sidekiq``)
20
- * ``Delayed::Job`` (``:delayed_job``)
21
- * Rake (``:rake``)
22
- * Rack (``:rack``)
23
- * Rails (``:railties``)
24
-
25
-
26
- Manually using integrations
27
- ---------------------------
28
-
29
- Integrations are automatically loaded by default. This can be problematic if
30
- the default integration behavior doesn't suit your projects' needs.
31
-
32
- To explicitly include integrations:
33
-
34
- .. sourcecode:: ruby
35
-
36
- require 'sentry-raven-without-integrations'
37
- Raven.inject_only(:railties, :rack, :rake)
38
-
39
-
40
- To blacklist integrations:
41
-
42
- .. sourcecode:: ruby
43
-
44
- require 'sentry-raven-without-integrations'
45
- Raven.inject_without(:sidekiq, :delayed_job)
46
-
47
-
48
- If you're using bundler, then in your gemfile:
49
-
50
- .. sourcecode:: ruby
51
-
52
- gem 'sentry-raven', require: 'sentry-raven-without-integrations'
53
-
54
-
55
- And in some sort of initializer:
56
-
57
- .. sourcecode:: ruby
58
-
59
- Raven.inject_without(:sidekiq)
@@ -1,30 +0,0 @@
1
- Puma
2
- ====
3
-
4
- Installation
5
- ------------
6
-
7
- Install the SDK via Rubygems by adding it to your ``Gemfile``:
8
-
9
- .. sourcecode:: ruby
10
-
11
- gem "sentry-raven"
12
-
13
- Configuration
14
- -------------
15
-
16
- Puma provides a config option for handling low level errors.
17
-
18
- .. sourcecode:: ruby
19
-
20
- # in your puma.rb config
21
- lowlevel_error_handler do |ex, env|
22
- Raven.capture_exception(
23
- ex,
24
- :message => ex.message,
25
- :extra => { :puma => env },
26
- :transaction => "Puma"
27
- )
28
- # note the below is just a Rack response
29
- [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
30
- end
@@ -1,27 +0,0 @@
1
- Rack (Sinatra etc.)
2
- ===================
3
-
4
- Installation
5
- ------------
6
-
7
- Install the SDK via Rubygems by adding it to your ``Gemfile``:
8
-
9
- .. sourcecode:: ruby
10
-
11
- gem "sentry-raven"
12
-
13
- Configuration
14
- -------------
15
-
16
- Add ``use Raven::Rack`` to your ``config.ru`` or other rackup file (this is
17
- automatically inserted in Rails):
18
-
19
- .. sourcecode:: ruby
20
-
21
- require 'raven'
22
-
23
- Raven.configure do |config|
24
- config.dsn = '___DSN___'
25
- end
26
-
27
- use Raven::Rack
@@ -1,62 +0,0 @@
1
- Ruby on Rails
2
- =============
3
-
4
- In Rails, all uncaught exceptions will be automatically reported.
5
-
6
- We support Rails 4 and newer.
7
-
8
- Installation
9
- ------------
10
-
11
- Install the SDK via Rubygems by adding it to your ``Gemfile``:
12
-
13
- .. sourcecode:: ruby
14
-
15
- gem "sentry-raven"
16
-
17
- Configuration
18
- -------------
19
-
20
- Open up ``config/application.rb`` and configure the DSN, and any other :doc:`settings <../config>`
21
- you need:
22
-
23
- .. sourcecode:: ruby
24
-
25
- Raven.configure do |config|
26
- config.dsn = '___DSN___'
27
- end
28
-
29
- If you have added items to `Rails' log filtering
30
- <http://guides.rubyonrails.org/action_controller_overview.html#parameters-filtering>`_,
31
- you can also make sure that those items are not sent to Sentry:
32
-
33
- .. sourcecode:: ruby
34
-
35
- # in your application.rb:
36
- config.filter_parameters << :password
37
-
38
- # in an initializer, like sentry.rb
39
- Raven.configure do |config|
40
- config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
41
- end
42
-
43
- Params and sessions
44
- -------------------
45
-
46
- .. sourcecode:: ruby
47
-
48
- class ApplicationController < ActionController::Base
49
- before_action :set_raven_context
50
-
51
- private
52
-
53
- def set_raven_context
54
- Raven.user_context(id: session[:current_user_id]) # or anything else in session
55
- Raven.extra_context(params: params.to_unsafe_h, url: request.url)
56
- end
57
- end
58
-
59
- Caveats
60
- -------
61
-
62
- Currently, custom exception applications (`config.exceptions_app`) are not supported. If you are using a custom exception app, you must manually integrate Raven yourself.