class Raven::Instance
- Raven::Instance
- Reference
- Object
Overview
A copy of Raven's base module class methods, minus some of the integration and global hooks since it's meant to be used explicitly. Useful for sending errors to multiple sentry projects in a large application.
class Foo
def initialize
@other_raven = Raven::Instance.new
@other_raven.configure do |config|
config.dsn = "http://..."
end
end
def foo
# ...
rescue ex
@other_raven.capture(ex)
end
end
Defined in:
raven/instance.crConstructors
Instance Method Summary
-
#annotate_exception(ex : Exception, **options)
Provides extra context to the exception prior to it being handled by Raven.
- #breadcrumbs
-
#capture(klass : String, message : String, backtrace : String | Nil = nil, **options, &)
Captures an exception with given klass, message and optional backtrace.
-
#capture(obj : Exception | String, **options, &)
Captures given
Exception
orString
object and yields createdRaven::Event
before sending to Sentry. -
#capture(obj : Exception | String, **options)
Captures given
Exception
orString
object. -
#capture(**options, &)
Capture and process any exceptions from the given block.
-
#captured_exception?(ex : Exception)
Returns
true
in case given ex was already captured,false
otherwise. -
#client : Client
The client object is responsible for delivering formatted data to the Sentry server.
-
#client=(client : Client)
The client object is responsible for delivering formatted data to the Sentry server.
-
#configuration : Configuration
See
Raven::Configuration
. -
#configuration=(configuration : Configuration)
See
Raven::Configuration
. -
#configure
Call this method to modify defaults in your initializers.
-
#configure(&)
Call this method to modify defaults in your initializers.
- #context
-
#extra_context(hash = nil, **options)
Bind extra context.
-
#extra_context(hash = nil, **options, &)
Bind extra context.
- #last_event_id
-
#report_status
Tell the log that the client is good to go.
-
#send_event(event, hint = nil)
Send an event to the configured Sentry server.
-
#send_feedback(event_id : String, data : Hash)
Sends User Feedback to Sentry server.
-
#tags_context(hash = nil, **options)
Bind tags context.
-
#tags_context(hash = nil, **options, &)
Bind tags context.
-
#user_context(hash = nil, **options)
Bind user context.
-
#user_context(hash = nil, **options, &)
Bind user context.
Constructor Detail
Instance Method Detail
Provides extra context to the exception prior to it being handled by Raven. An exception can have multiple annotations, which are merged together.
The options (annotation) is treated the same as the options
parameter to #capture
or Event.from
, and
can contain the same :user
, :tags
, etc. options as these methods.
These will be merged with the options parameter to
Event.from
at the top of execution.
begin
raise "Hello"
rescue ex
Raven.annotate_exception(ex, user: {id: 1, email: "foo@example.com"})
raise ex
end
Captures an exception with given klass, message and optional backtrace.
Raven.capture "FooBarError", "Foo got bar!"
NOTE Useful in scenarios where you need to reconstruct the error (usually along with a backtrace from external source), while having no access to the actual Exception object.
Captures given Exception
or String
object and yields
created Raven::Event
before sending to Sentry.
Raven.capture("boo!") do |event|
event.extra.merge! foo: "bar"
end
Captures given Exception
or String
object.
begin
# ...
rescue ex
Raven.capture ex
end
Raven.capture "boo!"
Capture and process any exceptions from the given block.
Raven.capture do
MyApp.run
end
Returns true
in case given ex was already captured,
false
otherwise.
ex = Exception.new("boo!")
Raven.captured_exception?(ex) # => false
Raven.capture(ex)
Raven.captured_exception?(ex) # => true
The client object is responsible for delivering formatted data to the Sentry server.
The client object is responsible for delivering formatted data to the Sentry server.
Call this method to modify defaults in your initializers.
Raven.configure do |config|
config.dsn = "http://..."
end
Call this method to modify defaults in your initializers.
Raven.configure do |config|
config.dsn = "http://..."
end
Bind extra context. Merges with existing context (if any).
Extra context shows up as Additional Data within Sentry, and is completely arbitrary.
Raven.extra_context(my_custom_data: "value")
Bind extra context. Merges with existing context (if any).
See #extra_context
Send an event to the configured Sentry server.
event = Raven::Event.new(message: "An error")
Raven.send_event(event)
Sends User Feedback to Sentry server.
data should be a Hash(String, String)
with following keys:
- name (populated from
context.user[:username]
if left empty) - email (populated from
context.user[:email]
if left empty) - comments
Raven.send_feedback(Raven.last_event_id, {
"name" => "...",
"email" => "...",
"comments" => "...",
})
NOTE Sentry server records single (last) feedback for a given event_id.
Bind tags context. Merges with existing context (if any).
Tags are key / value pairs which generally represent things like application version, environment, role, and server names.
Raven.tags_context(my_custom_tag: "tag_value")
Bind tags context. Merges with existing context (if any).
See #tags_context
Bind user context. Merges with existing context (if any).
It is recommending that you send at least the :id
and :email
values. All other values are arbitrary.
Raven.user_context(id: 1, email: "foo@example.com")
Bind user context. Merges with existing context (if any).
See #user_context