1Sentry::Raven(3)      User Contributed Perl Documentation     Sentry::Raven(3)
2
3
4

NAME

6       Sentry::Raven - A perl sentry client
7

VERSION

9       Version 1.13
10

SYNOPSIS

12         my $raven = Sentry::Raven->new( sentry_dsn => 'https://<publickey>:<secretkey>@sentry.io/<projectid>' );
13
14         # capture all errors
15         $raven->capture_errors( sub {
16             ..do something here..
17         } );
18
19         # capture an individual event
20         $raven->capture_message('The sky is falling');
21
22         # annotate an event with context
23         $raven->capture_message(
24           'The sky is falling',
25           Sentry::Raven->exception_context('SkyException', 'falling'),
26         );
27

DESCRIPTION

29       This module implements the recommended raven interface for posting
30       events to a sentry service.
31

CONSTRUCTOR

33   my $raven = Sentry::Raven->new( %options, %context )
34       Create a new sentry interface object.  It accepts the following named
35       options:
36
37       "sentry_dsn => 'http://<publickey>:<secretkey>@sentry.io/<projectid>'"
38           The DSN for your sentry service.  Get this from the client
39           configuration page for your project.
40
41       "timeout => 5"
42           Do not wait longer than this number of seconds when attempting to
43           send an event.
44

ERROR HANDLERS

46       These methods are designed to capture events and handle them
47       automatically.
48
49   $raven->capture_errors( $subref, %context )
50       Execute the $subref and report any exceptions (die) back to the sentry
51       service.  If it is unable to submit an event (capture_message return
52       undef), it will die and include the event details in the die message.
53       This automatically includes a stacktrace unless $SIG{__DIE__} has been
54       overridden in subsequent code.
55

METHODS

57       These methods are for generating individual events.
58
59   $raven->capture_message( $message, %context )
60       Post a string message to the sentry service.  Returns the event id.
61
62   $raven->capture_exception( $exception_value, %exception_context, %context )
63       Post an exception type and value to the sentry service.  Returns the
64       event id.
65
66       %exception_context can contain:
67
68       "type => $type"
69
70   $raven->capture_request( $url, %request_context, %context )
71       Post a web url request to the sentry service.  Returns the event id.
72
73       %request_context can contain:
74
75       "method => 'GET'"
76       "data => 'foo=bar'"
77       "query_string => 'foo=bar'"
78       "cookies => 'foo=bar'"
79       "headers => { 'Content-Type' => 'text/html' }"
80       "env => { REMOTE_ADDR => '192.168.0.1' }"
81
82   $raven->capture_stacktrace( $frames, %context )
83       Post a stacktrace to the sentry service.  Returns the event id.
84
85       $frames can be either a Devel::StackTrace object, or an arrayref of
86       hashrefs with each hashref representing a single frame.
87
88           my $frames = [
89               {
90                   filename => 'my/file1.pl',
91                   function => 'function1',
92                   vars     => { foo => 'bar' },
93                   lineno   => 10,
94               },
95               {
96                   filename => 'my/file2.pl',
97                   function => 'function2',
98                   vars     => { bar => 'baz' },
99                   lineno   => 20,
100               },
101           ];
102
103       The first frame should be the oldest frame.  Frames must contain at
104       least one of "filename", "function", or "module".  These additional
105       attributes are also supported:
106
107       "filename => $file_name"
108       "function => $function_name"
109       "module => $module_name"
110       "lineno => $line_number"
111       "colno => $column_number"
112       "abs_path => $absolute_path_file_name"
113       "context_line => $line_of_code"
114       "pre_context => [ $previous_line1, $previous_line2 ]"
115       "post_context => [ $next_line1, $next_line2 ]"
116       "in_app => $one_if_not_external_library"
117       "vars => { $variable_name => $variable_value }"
118
119   $raven->capture_user( %user_context, %context )
120       Post a user to the sentry service.  Returns the event id.
121
122       %user_context can contain:
123
124       "id => $unique_id"
125       "username => $username"
126       "email => $email"
127       "ip_address => $ip_address"
128
129   $raven->capture_query( $query, %query_context, %context )
130       Post a query to the sentry service.  Returns the event id.
131
132       %query_context can contain:
133
134       "engine => $engine'"
135

EVENT CONTEXT

137       These methods are for annotating events with additional context, such
138       as stack traces or HTTP requests.  Simply pass their output to any
139       other method accepting %context.  They accept all of the same arguments
140       as their "capture_*" counterparts.
141
142         $raven->capture_message(
143           'The sky is falling',
144           Sentry::Raven->exception_context('falling', type => 'SkyException'),
145         );
146
147   Sentry::Raven->exception_context( $value, %exception_context )
148   Sentry::Raven->request_context( $url, %request_context )
149   Sentry::Raven->stacktrace_context( $frames )
150   Sentry::Raven->user_context( %user_context )
151   Sentry::Raven->query_context( $query, %query_context )
152       The default context can be modified with the following accessors:
153
154   my %context = $raven->get_context();
155   $raven->add_context( %context )
156   $raven->merge_tags( %tags )
157       Merge additional tags into any existing tags in the current context.
158
159   $raven->merge_extra( %tags )
160       Merge additional extra into any existing extra in the current context.
161
162   $raven->clear_context()

EVENT PROCESSORS

164       Processors are a mechanism for modifying events after they are
165       generated but before they are posted to the sentry service.  They are
166       useful for scrubbing sensitive data, such as passwords, as well as
167       adding additional context.  If the processor fails (dies or returns
168       undef), the failure will be passed to the caller.
169
170       See Sentry::Raven::Processor for information on creating new
171       processors.
172
173       Available processors:
174
175       Sentry::Raven::Processor::RemoveStackVariables
176
177   $raven->add_processors( [ Sentry::Raven::Processor::RemoveStackVariables,
178       ... ] )
179   $raven->clear_processors( [ Sentry::Raven::Processor::RemoveStackVariables,
180       ... ] )

STANDARD OPTIONS

182       These options can be passed to all methods accepting %context.  Passing
183       context to the constructor overrides defaults.
184
185       "culprit => 'Some::Software'"
186           The source of the event.  Defaults to "undef".
187
188       "event_id => '534188f7c1ff4ff280c2e1206c9e0548'"
189           The unique identifier string for an event, usually UUID v4.  Max 32
190           characters.  Defaults to a new unique UUID for each event.  Invalid
191           ids may be discarded silently.
192
193       "extra => { key1 => 'val1', ... }"
194           Arbitrary key value pairs with extra information about an event.
195           Defaults to "{}".
196
197       "level => 'error'"
198           Event level of an event.  Acceptable values are "fatal", "error",
199           "warning", "info", and "debug".  Defaults to "error".
200
201       "logger => 'root'"
202           The creator of an event.  Defaults to 'root'.
203
204       "platform => 'perl'"
205           The platform (language) in which an event occurred.  Defaults to
206           "perl".
207
208       "release => 'ec899ea'"
209           Track the release version of your application.
210
211       "processors => [ Sentry::Raven::Processor::RemoveStackVariables, ... ]"
212           A set or processors to be applied to events before they are posted.
213           See Sentry::Raven::Processor for more information.  This can only
214           be set during construction and not on other methods accepting
215           %context.
216
217       "server_name => 'localhost.example.com'"
218           The hostname on which an event occurred.  Defaults to the system
219           hostname.
220
221       "tags => { key1 => 'val1, ... }"
222           Arbitrary key value pairs with tags for categorizing an event.
223           Defaults to "{}".
224
225       "fingerprint => [ 'val1', 'val2', ... }"
226           Array of strings used to control how events aggregate in the sentry
227           web interface. The string '{{ default }}' has special meaning when
228           used as the first value; it indicates that sentry should use the
229           default aggregation method in addition to any others specified
230           (useful for fine-grained aggregation). Defaults to "['{{ default
231           }}']".
232
233       "timestamp => '1970-01-01T00:00:00'"
234           Timestamp of an event.  ISO 8601 format.  Defaults to the current
235           time.  Invalid values may be discarded silently.
236
237       "environment => 'production'"
238           Specify the environment (i.e. staging, production, etc.) that your
239           project is deployed in. More information can be found on the Sentry
240           website <https://docs.sentry.io/enriching-error-
241           data/environments/>.
242

CONFIGURATION AND ENVIRONMENT

244       SENTRY_DSN="http://<publickey>:<secretkey>@sentry.io/<projectid>"
245           A default DSN to be used if sentry_dsn is not passed to c<new>.
246

LICENSE

248       Copyright (C) 2019 by Matt Harrington
249
250       The full text of this license can be found in the LICENSE file included
251       with this module.
252
253
254
255perl v5.32.0                      2020-07-28                  Sentry::Raven(3)
Impressum