| 1 | package OpenTracing::Role::Scope; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 10 | our $VERSION = 'v0.86.1'; | |||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use MooX::Should; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use OpenTracing::Types qw/Span/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use Types::Standard qw/Bool CodeRef Maybe/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 10 | has span => ( | |||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||
| 14 | should => Span, | ||||||||||||||||||||||||||||||||
| 15 | reader => 'get_span', | ||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 10 | has finish_span_on_close => ( | |||||||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||||||
| 20 | should => Bool, | ||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 10 | has closed => ( | |||||||||||||||||||||||||||||||
| 24 | is => 'rwp', | ||||||||||||||||||||||||||||||||
| 25 | should => Bool, | ||||||||||||||||||||||||||||||||
| 26 | init_arg => undef, | ||||||||||||||||||||||||||||||||
| 27 | default => !!undef, | ||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 10 | has on_close => ( | |||||||||||||||||||||||||||||||
| 31 | is => 'ro', | ||||||||||||||||||||||||||||||||
| 32 | should => Maybe[CodeRef], | ||||||||||||||||||||||||||||||||
| 33 | predicate => 1, | ||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | sub close { | ||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 37 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 7 | ▶ | carp "Can't close an already closed scope" and return $self | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$self->closed && (carp(q[Can't close an already closed scope]) && (return $self))
carp("Can't close an already closed scope") and return $self
MC/DC0%0/2
$self->closed && (carp(q[Can't close an already closed scope]) && (return $self))
$self->closed
carp("Can't close an already closed scope")
Truth table33%1/3
A && B
A= $self->closedB= carp("Can't close an already closed scope")
| |||||||||||||||||||||||||||||||||
| 40 | if $self->closed; | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 6 | $self->_set_closed( !undef ); | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | $self->get_span->finish | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | if $self->finish_span_on_close; | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | $self->on_close->( $self ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | if $self->has_on_close; | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | # return $self->get_scope_manager()->deactivate_scope( $self ); | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 6 | return $self | |||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | sub DEMOLISH { | ||||||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 57 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||
| 58 | 5 | my $in_global_destruction = shift; | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | return if $self->closed; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 2 | croak "Scope not programmatically closed before being demolished"; | |||||||||||||||||||||||||||||||
| 63 | # | ||||||||||||||||||||||||||||||||
| 64 | # below might be appreciated behaviour, but you should close yourself | ||||||||||||||||||||||||||||||||
| 65 | # | ||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $self->close( ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | unless $in_global_destruction; | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | return | ||||||||||||||||||||||||||||||||
| 70 | 0 | } | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 10 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 75 | 10 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 76 | 10 | with 'OpenTracing::Interface::Scope' | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 10 | 1; | |||||||||||||||||||||||||||||||