| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | use Mojo::Base 'Mojolicious::Plugin', -signatures; | 
| 2 | 1 |  |  | 1 |  | 203143 |  | 
|  | 1 |  |  |  |  | 9 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 3 |  |  |  |  |  |  | use Sentry::SDK; | 
| 4 | 1 |  |  | 1 |  | 1193 | use Try::Tiny; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 5 | 1 |  |  | 1 |  | 33 |  | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 474 |  | 
| 6 |  |  |  |  |  |  | $app->hook( | 
| 7 | 3 |  |  | 3 | 1 | 39887 | before_server_start => sub ($server, $app) { | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 4 |  | 
|  | 3 |  |  |  |  | 4 |  | 
| 8 | 6 |  |  |  |  | 11 | Sentry::SDK->init($conf); | 
| 9 | 6 |  |  | 6 |  | 8 | } | 
|  | 6 |  |  |  |  | 7162 |  | 
|  | 6 |  |  |  |  | 7 |  | 
| 10 | 6 |  |  |  |  | 27 | ); | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 3 |  |  |  |  | 17 | $app->hook( | 
| 13 |  |  |  |  |  |  | around_action => sub ($next, $c, $action, $last) { | 
| 14 | 3 |  |  |  |  | 4 | return $next->() unless $last; | 
| 15 | 3 |  |  | 3 |  | 5 |  | 
|  | 3 |  |  |  |  | 30361 |  | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 4 |  | 
|  | 3 |  |  |  |  | 19 |  | 
| 16 | 3 | 50 |  |  |  | 14 | my $req = $c->req; | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 3 |  |  |  |  | 13 | Sentry::Hub->get_current_hub()->with_scope(sub ($scope) { | 
| 19 |  |  |  |  |  |  | my %cookies = map { ($_->name, $_->value) } ($req->cookies // [])->@*; | 
| 20 | 3 |  |  |  |  | 10 | my $transaction = Sentry::SDK->start_transaction( | 
| 21 | 3 |  | 50 |  |  | 13 | { | 
|  | 0 |  |  |  |  | 0 |  | 
| 22 | 3 |  | 100 |  |  | 147 | name    => $c->match->endpoint->pattern->unparsed || '/', | 
| 23 |  |  |  |  |  |  | op      => 'http.server', | 
| 24 |  |  |  |  |  |  | request => { | 
| 25 |  |  |  |  |  |  | url          => $req->url->to_abs->to_string, | 
| 26 |  |  |  |  |  |  | cookies      => \%cookies, | 
| 27 |  |  |  |  |  |  | method       => $req->method, | 
| 28 |  |  |  |  |  |  | query_string => $req->url->query->to_hash, | 
| 29 |  |  |  |  |  |  | headers      => $req->headers->to_hash, | 
| 30 |  |  |  |  |  |  | env          => \%ENV, | 
| 31 |  |  |  |  |  |  | }, | 
| 32 |  |  |  |  |  |  | }, | 
| 33 |  |  |  |  |  |  | ); | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | Sentry::SDK->configure_scope(sub ($scope) { | 
| 36 |  |  |  |  |  |  | $scope->set_span($transaction); | 
| 37 | 3 |  |  |  |  | 5 | }); | 
| 38 | 3 |  |  |  |  | 9 |  | 
| 39 | 3 |  |  |  |  | 31 | try { | 
| 40 |  |  |  |  |  |  | $next->(); | 
| 41 |  |  |  |  |  |  | } catch { | 
| 42 | 3 |  |  |  |  | 211 | Sentry::SDK->capture_exception($_); | 
| 43 |  |  |  |  |  |  | $c->reply->exception($_) | 
| 44 | 1 |  |  |  |  | 484 | } finally { | 
| 45 | 1 |  |  |  |  | 10 | my $status = $c->res->code; | 
| 46 |  |  |  |  |  |  | $transaction->set_http_status($status) if $status; | 
| 47 | 3 |  |  |  |  | 51623 | $transaction->finish(); | 
| 48 | 3 | 50 |  |  |  | 51 | }; | 
| 49 | 3 |  |  |  |  | 24 | }); | 
| 50 | 3 |  |  |  |  | 23 | } | 
| 51 | 3 |  |  |  |  | 37 | ); | 
| 52 |  |  |  |  |  |  | } | 
| 53 | 3 |  |  |  |  | 40 |  | 
| 54 |  |  |  |  |  |  | 1; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | =encoding utf8 | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head1 NAME | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | Mojolicious::Plugin::SentrySDK - Sentry plugin for Mojolicious | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =head1 OPTIONS | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head2 register | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | my $config = $plugin->register(Mojolicious->new); | 
| 71 |  |  |  |  |  |  | my $config = $plugin->register(Mojolicious->new, \%options); | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | Register Sentry in L<Mojolicious> application. | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | L<Sentry::SDK>. | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =cut |