| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | use Mojo::Base -base, -signatures; | 
| 2 | 5 |  |  | 5 |  | 194784 |  | 
|  | 5 |  |  |  |  | 17 |  | 
|  | 5 |  |  |  |  | 29 |  | 
| 3 |  |  |  |  |  |  | use Clone qw(); | 
| 4 | 5 |  |  | 5 |  | 2763 | use Mojo::Util 'dumper'; | 
|  | 5 |  |  |  |  | 10452 |  | 
|  | 5 |  |  |  |  | 119 |  | 
| 5 | 5 |  |  | 5 |  | 26 | use Sentry::Severity; | 
|  | 5 |  |  |  |  | 10 |  | 
|  | 5 |  |  |  |  | 191 |  | 
| 6 | 5 |  |  | 5 |  | 1695 | use Sentry::Tracing::Span; | 
|  | 5 |  |  |  |  | 10 |  | 
|  | 5 |  |  |  |  | 39 |  | 
| 7 | 5 |  |  | 5 |  | 1885 | use Sentry::Util 'merge'; | 
|  | 5 |  |  |  |  | 12 |  | 
|  | 5 |  |  |  |  | 37 |  | 
| 8 | 5 |  |  | 5 |  | 169 | use Time::HiRes; | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 198 |  | 
| 9 | 5 |  |  | 5 |  | 26 |  | 
|  | 5 |  |  |  |  | 10 |  | 
|  | 5 |  |  |  |  | 17 |  | 
| 10 |  |  |  |  |  |  | has breadcrumbs            => sub { [] }; | 
| 11 |  |  |  |  |  |  | has contexts               => sub { {} }; | 
| 12 |  |  |  |  |  |  | has error_event_processors => sub { [] }; | 
| 13 |  |  |  |  |  |  | has event_processors       => sub { [] }; | 
| 14 |  |  |  |  |  |  | has extra                  => sub { {} }; | 
| 15 |  |  |  |  |  |  | has fingerprint            => sub { [] }; | 
| 16 |  |  |  |  |  |  | has level                  => Sentry::Severity->Info; | 
| 17 |  |  |  |  |  |  | has span                   => undef; | 
| 18 |  |  |  |  |  |  | has tags                   => sub { {} }; | 
| 19 |  |  |  |  |  |  | has transaction_name       => undef; | 
| 20 |  |  |  |  |  |  | has user                   => undef; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | $self->span($span); | 
| 23 | 8 |  |  | 8 | 0 | 9 | return $self; | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 10 |  | 
|  | 8 |  |  |  |  | 10 |  | 
| 24 | 8 |  |  |  |  | 19 | } | 
| 25 | 8 |  |  |  |  | 51 |  | 
| 26 |  |  |  |  |  |  | $self->user($user); | 
| 27 |  |  |  |  |  |  | } | 
| 28 | 1 |  |  | 1 | 0 | 6 |  | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 2 |  | 
| 29 | 1 |  |  |  |  | 3 | $self->extra->{$name} = $value; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 0 |  |  | 0 | 0 | 0 | $self->extra = { %{ $self->extra }, %{$extras} }; | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 33 | 0 |  |  |  |  | 0 | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | $self->tags->{$key} = $value; | 
| 36 | 0 |  |  | 0 | 0 | 0 | } | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 37 | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 38 |  |  |  |  |  |  | $self->tags({ $self->tags->%*, $tags->%* }); | 
| 39 |  |  |  |  |  |  | } | 
| 40 | 1 |  |  | 1 | 0 | 12 |  | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 2 |  | 
| 41 | 1 |  |  |  |  | 3 | if (not defined $context) { | 
| 42 |  |  |  |  |  |  | delete $self->contexts->{$key}; | 
| 43 |  |  |  |  |  |  | } else { | 
| 44 | 15 |  |  | 15 | 0 | 105 | $self->contexts->{$key} = $context; | 
|  | 15 |  |  |  |  | 16 |  | 
|  | 15 |  |  |  |  | 16 |  | 
|  | 15 |  |  |  |  | 15 |  | 
| 45 | 15 |  |  |  |  | 32 | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | # $self->_notify_scope_listeners(); | 
| 48 | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 49 | 0 | 0 |  |  |  | 0 | return $self; | 
| 50 | 0 |  |  |  |  | 0 | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 0 |  |  |  |  | 0 | $self->level($level); | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | $self->transaction_name($name); | 
| 56 |  |  |  |  |  |  | return $self; | 
| 57 | 0 |  |  |  |  | 0 | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | return $self->span; | 
| 60 | 0 |  |  | 0 | 0 | 0 | } | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 61 | 0 |  |  |  |  | 0 |  | 
| 62 |  |  |  |  |  |  | $self->fingerprint($fingerprint); | 
| 63 |  |  |  |  |  |  | } | 
| 64 | 0 |  |  | 0 | 0 | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 65 | 0 |  |  |  |  | 0 | push $self->event_processors->@*, $event_processor; | 
| 66 | 0 |  |  |  |  | 0 | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | push $self->error_event_processors->@*, $error_event_processor; | 
| 69 | 2 |  |  | 2 | 0 | 14 | } | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 3 |  | 
| 70 | 2 |  |  |  |  | 5 |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | # Resets a scope to default values while keeping all registered event | 
| 73 | 0 |  |  | 0 | 0 | 0 | # processors. This does not affect either child or parent scopes | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 74 | 0 |  |  |  |  | 0 | } | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | $breadcrumb->{timestamp} //= time; | 
| 77 | 0 |  |  | 0 | 0 | 0 | push @{ $self->breadcrumbs }, $breadcrumb; | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 78 | 0 |  |  |  |  | 0 | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | $self->breadcrumbs([]); | 
| 81 | 0 |  |  | 0 | 0 | 0 | } | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 82 | 0 |  |  |  |  | 0 |  | 
| 83 |  |  |  |  |  |  | # Applies fingerprint from the scope to the event if there's one, | 
| 84 |  |  |  |  |  |  | # uses message if there's one instead or get rid of empty fingerprint | 
| 85 | 0 |  |  | 0 | 0 | 0 | $event->{fingerprint} //= []; | 
|  | 0 |  |  |  |  | 0 |  | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | $event->{fingerprint} = [$event->{fingerprint}] | 
| 88 |  |  |  |  |  |  | if ref($event->{fingerprint} ne 'ARRAY'); | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | $event->{fingerprint} = [$event->{fingerprint}->@*, $self->fingerprint->@*]; | 
| 91 | 15 |  |  | 15 | 0 | 46 |  | 
|  | 15 |  |  |  |  | 19 |  | 
|  | 15 |  |  |  |  | 18 |  | 
|  | 15 |  |  |  |  | 16 |  | 
| 92 | 15 |  | 66 |  |  | 70 | delete $event->{fingerprint} unless scalar $event->{fingerprint}->@*; | 
| 93 | 15 |  |  |  |  | 25 | } | 
|  | 15 |  |  |  |  | 36 |  | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | # Applies the scope data to the given event object. This also applies the event | 
| 96 | 0 |  |  | 0 | 0 | 0 | # processors stored in the scope internally. Some implementations might want to | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 97 | 0 |  |  |  |  | 0 | # set a max breadcrumbs count here. | 
| 98 |  |  |  |  |  |  | merge($event, $self, 'extra')    if $self->extra; | 
| 99 |  |  |  |  |  |  | merge($event, $self, 'tags')     if $self->tags; | 
| 100 |  |  |  |  |  |  | merge($event, $self, 'user')     if $self->user; | 
| 101 |  |  |  |  |  |  | merge($event, $self, 'contexts') if $self->contexts; | 
| 102 | 21 |  |  | 21 |  | 27 |  | 
|  | 21 |  |  |  |  | 26 |  | 
|  | 21 |  |  |  |  | 26 |  | 
|  | 21 |  |  |  |  | 17 |  | 
| 103 | 21 |  | 50 |  |  | 86 | $event->{level} //= $self->level                if $self->level; | 
| 104 |  |  |  |  |  |  | $event->{transaction} = $self->transaction_name if $self->transaction_name; | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 21 | 50 |  |  |  | 76 | if ($self->span) { | 
| 107 |  |  |  |  |  |  | $event->{request} = $self->span->request; | 
| 108 | 21 |  |  |  |  | 70 |  | 
| 109 |  |  |  |  |  |  | $event->{contexts} = { | 
| 110 | 21 | 50 |  |  |  | 81 | trace => $self->span->get_trace_context(), | 
| 111 |  |  |  |  |  |  | ($event->{contexts} // {})->%* | 
| 112 |  |  |  |  |  |  | }; | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | if (my $transaction_name = $self->span->transaction->name) { | 
| 115 |  |  |  |  |  |  | $event->{tags} | 
| 116 | 21 |  |  | 21 | 0 | 809 | = { transaction => $transaction_name, ($event->{tags} // {})->%* }; | 
|  | 21 |  |  |  |  | 27 |  | 
|  | 21 |  |  |  |  | 23 |  | 
|  | 21 |  |  |  |  | 26 |  | 
|  | 21 |  |  |  |  | 23 |  | 
| 117 | 21 | 50 |  |  |  | 45 | } | 
| 118 | 21 | 50 |  |  |  | 63 | } | 
| 119 | 21 | 50 |  |  |  | 68 |  | 
| 120 | 21 | 50 |  |  |  | 99 | $self->_apply_fingerprint($event); | 
| 121 |  |  |  |  |  |  |  | 
| 122 | 21 | 50 | 66 |  |  | 86 | $event->{breadcrumbs} | 
| 123 | 21 | 50 |  |  |  | 206 | = [($event->{breadcrumbs} // [])->@*, $self->breadcrumbs->@*]; | 
| 124 |  |  |  |  |  |  |  | 
| 125 | 21 | 100 |  |  |  | 92 | my @event_processors | 
| 126 | 20 |  |  |  |  | 85 | = (get_global_event_processors()->@*, $self->event_processors->@*); | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | foreach my $processor (@event_processors) { | 
| 129 |  |  |  |  |  |  | $event = $processor->($event, $hint); | 
| 130 | 20 |  | 50 |  |  | 115 | } | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | return $event; | 
| 133 | 20 | 50 |  |  |  | 216 | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 | 20 |  | 50 |  |  | 214 | Clone::clone($self); | 
| 136 |  |  |  |  |  |  | } | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | $self->$_($fields->{$_}) for keys $fields->%*; | 
| 139 | 21 |  |  |  |  | 66 | } | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | state $processors = []; | 
| 142 | 21 |  | 50 |  |  | 108 | return $processors; | 
| 143 |  |  |  |  |  |  | } | 
| 144 |  |  |  |  |  |  |  | 
| 145 | 21 |  |  |  |  | 94 | push get_global_event_processors()->@*, $processor; | 
| 146 |  |  |  |  |  |  | } | 
| 147 | 21 |  |  |  |  | 65 |  | 
| 148 | 1 |  |  |  |  | 3 | 1; |