Sentry::Raven(3)
πΈ NAME πΈ
Sentry::Raven β A perl sentry client. This is the Sentry::Raven(3) manual page from the User Contributed Perl Documentation crew, and yes, we're making it a whole vibe π.
β¨ VERSION β¨
Version 1.14 β slay, that's the version, bestie.
π SYNOPSIS π
Okay so here's the vibe in code, no cap:
my $raven = Sentry::Raven->new( sentry_dsn => 'https://<publickey>:<secretkey>@sentry.io/<projectid>' );
# capture all errors
$raven->capture_errors( sub {
..do something here..
} );
# capture an individual event
$raven->capture_message('The sky is falling');
# annotate an event with context
$raven->capture_message(
'The sky is falling',
Sentry::Raven->exception_context('SkyException', 'falling'),
);
π¦ DESCRIPTION π¦
This module implements the recommended raven interface for posting events to a sentry service. Periodt π . Like, that's literally the whole thing, but here's the rest so you can actually use it.
π CONSTRUCTOR π
my $raven = Sentry::Raven->new( %options, %context )
Create a new sentry interface object. It accepts these named options:
sentry_dsn => 'http://<publickey>:<secretkey>@sentry.io/<projectid>'β The DSN for your sentry service. Get this from the client configuration page for your project. You know, the lil setup page.timeout => 5β Do not wait longer than this number of seconds when attempting to send an event. Timeout queen behavior β³.
π¨ ERROR HANDLERS π¨
These methods are designed to capture events and handle them automatically. Main character energy, fr.
$raven->capture_errors( $subref, %context )
Execute the $subref and report any exceptions (die) back to the sentry service. If it is unable to submit an event (capture_message return undef), it will die and include the event details in the die message. This automatically includes a stacktrace unless $SIG{__DIE__} has been overridden in subsequent code. So yeah, it's giving "catch the chaos and tell Sentry" π.
π METHODS π
These methods are for generating individual events. One event at a time, but make it fashion β¨.
$raven->capture_message( $message, %context )
Post a string message to the sentry service. Returns the event id. Short, sweet, iconic.
$raven->capture_exception( $exception_value, %exception_context, %context )
Post an exception type and value to the sentry service. Returns the event id.
%exception_context can contain:
type => $type
$raven->capture_request( $url, %request_context, %context )
Post a web url request to the sentry service. Returns the event id.
%request_context can contain:
method => 'GET'data => 'foo=bar'query_string => 'foo=bar'cookies => 'foo=bar'headers => { 'Content-Type' => 'text/html' }env => { REMOTE_ADDR => '192.168.0.1' }
$raven->capture_stacktrace( $frames, %context )
Post a stacktrace to the sentry service. Returns the event id.
$frames can be either a Devel::StackTrace object, or an arrayref of hashrefs with each hashref representing a single frame.
my $frames = [
{
filename => 'my/file1.pl',
function => 'function1',
vars => { foo => 'bar' },
lineno => 10,
},
{
filename => 'my/file2.pl',
function => 'function2',
vars => { bar => 'baz' },
lineno => 20,
},
];
The first frame should be the oldest frame. Frames must contain at least one of filename, function, or module. These additional attributes are also supported:
filename => $file_namefunction => $function_namemodule => $module_namelineno => $line_numbercolno => $column_numberabs_path => $absolute_path_file_namecontext_line => $line_of_codepre_context => [ $previous_line1, $previous_line2 ]post_context => [ $next_line1, $next_line2 ]in_app => $one_if_not_external_libraryvars => { $variable_name => $variable_value }
$raven->capture_user( %user_context, %context )
Post a user to the sentry service. Returns the event id.
%user_context can contain:
id => $unique_idusername => $usernameemail => $emailip_address => $ip_address
$raven->capture_query( $query, %query_context, %context )
Post a query to the sentry service. Returns the event id.
%query_context can contain:
engine => $engine'β the query engine, and yes, that trailing apostrophe is literally in the original, iykyk π
π¦ EVENT CONTEXT π¦
These methods are for annotating events with additional context, such as stack traces or HTTP requests. Simply pass their output to any other method accepting %context. They accept all of the same arguments as their capture_* counterparts. So it's like adding lil accessories to your event before it walks the runway π
.
Example time:
$raven->capture_message(
'The sky is falling',
Sentry::Raven->exception_context('falling', type => 'SkyException'),
);
Then the signature squad:
Sentry::Raven->exception_context( $value, %exception_context )
Sentry::Raven->request_context( $url, %request_context )
Sentry::Raven->stacktrace_context( $frames )
Sentry::Raven->user_context( %user_context )
Sentry::Raven->query_context( $query, %query_context )
The default context can be modified with the following accessors:
my %context = $raven->get_context();$raven->add_context( %context )$raven->merge_tags( %tags )β Merge additional tags into any existing tags in the current context.$raven->merge_extra( %tags )β Merge additional extra into any existing extra in the current context.$raven->clear_context()
π§ EVENT PROCESSORS π§
Processors are a mechanism for modifying events after they are generated but before they are posted to the sentry service. They are useful for scrubbing sensitive data, such as passwords, as well as adding additional context. If the processor fails (dies or returns undef), the failure will be passed to the caller. So if a processor says "nope," the caller hears about it, periodt.
See Sentry::Raven::Processor for information on creating new processors.
Available processors:
Sentry::Raven::Processor::RemoveStackVariables
$raven->add_processors( [ Sentry::Raven::Processor::RemoveStackVariables, ... ] )
$raven->clear_processors( [ Sentry::Raven::Processor::RemoveStackVariables, ... ] )
β STANDARD OPTIONS β
These options can be passed to all methods accepting %context. Passing context to the constructor overrides defaults. Okay so these are the universal settings, bestie.
culprit => 'Some::Software'β The source of the event. Defaults toundef.event_id => '534188f7c1ff4ff280c2e1206c9e0548'β The unique identifier string for an event, usually UUID v4. Max 32 characters. Defaults to a new unique UUID for each event. Invalid ids may be discarded silently. K bye invalid ids π.extra => { key1 => 'val1', ... }β Arbitrary key value pairs with extra information about an event. Defaults to{}.level => 'error'β Event level of an event. Acceptable values arefatal,error,warning,info, anddebug. Defaults toerror.logger => 'root'β The creator of an event. Defaults to'root'.platform => 'perl'β The platform (language) in which an event occurred. Defaults toperl.release => 'ec899ea'β Track the release version of your application.processors => [ Sentry::Raven::Processor::RemoveStackVariables, ... ]β A set of processors to be applied to events before they are posted. SeeSentry::Raven::Processorfor more information. This can only be set during construction and not on other methods accepting%context. Note the original says "A set or processors" β keep that lil typo energy in your heart π«Ά.server_name => 'localhost.example.com'β The hostname on which an event occurred. Defaults to the system hostname.tags => { key1 => 'val1, ... }β Arbitrary key value pairs with tags for categorizing an event. Defaults to{}. The original has a lil quote gremlin in there; keep the code as it appears π.fingerprint => [ 'val1', 'val2', ... }β Array of strings used to control how events aggregate in the sentry web interface. The string'{{ default }}'has special meaning when used as the first value; it indicates that sentry should use the default aggregation method in addition to any others specified (useful for fine-grained aggregation). Defaults to['{{ default }}']. Again, the original has a}where your brain expects], so keep it cute and exact π«Ά.timestamp => '1970-01-01T00:00:00'β Timestamp of an event. ISO 8601 format. Defaults to the current time. Invalid values may be discarded silently.environment => 'production'β Specify the environment (i.e. staging, production, etc.) that your project is deployed in. More information can be found on the Sentry website athttps://docs.sentry.io/enriching-error-data/environments/.
π CONFIGURATION AND ENVIRONMENT π
SENTRY_DSN="http://<publickey>:<secretkey>@sentry.io/<projectid>"β A default DSN to be used ifsentry_dsnis not passed tonew.
π LICENSE π
Copyright (C) 2019 by Matt Harrington.
The full text of this license can be found in the LICENSE file included with this module.
That's the whole Sentry::Raven(3) page, bestie π«Άπ β perl v5.32.1, dated 2022-01-21, signing off. Stay iconic, and may your events always reach Sentry β¨ππ
π¦ where this page comes from
- epel 9: perl-Sentry-Raven 1.14-5.el9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms