Role/Scope.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 50.0% 1 / 2 totaltotal 89.2% 50 / 56 CC 7 SCAR 9.4
CC
7
Cov
89%
close
4.0
DEMOLISH
3.6
BEGIN
2.0
CRAP 2.6
« Role/Span.pm ↑ Summary Role/ScopeManager.pm »
1 package OpenTracing::Role::Scope;
2  
3 10 our $VERSION = 'v0.80.0-TRIAL_006';
4  
5 10 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use OpenTracing::Types qw/Span/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Types::Standard qw/Bool CodeRef Maybe/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 has span => (
12 is => 'ro',
13 isa => Span,
14 reader => 'get_span',
15 );
16  
17 10 has finish_span_on_close => (
18 is => 'ro',
19 isa => Bool,
20 );
21  
22 10 has closed => (
23 is => 'rwp',
24 isa => Bool,
25 init_arg => undef,
26 default => !!undef,
27 );
28  
29 10 has on_close => (
30 is => 'ro',
31 isa => Maybe[CodeRef],
32 predicate => 1,
33 );
34  
35 sub close {
36 7 ▶ my $self = shift;
Subroutine close: called CC=4 SCAR=13.9
Pod documented
37
38 7 ▶ croak "Can't close an already closed scope"
Branch: 1 branch
BranchTrueFalseTotal
if $self->closed 1 6 7
39 if $self->closed;
40
41 6 $self->_set_closed( !undef );
42
43 6 ▶ $self->get_span->finish
Branch: 1 branch
BranchTrueFalseTotal
if $self->finish_span_on_close 0 6 6
44 if $self->finish_span_on_close;
45
46 6 ▶ $self->on_close->( $self )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_on_close 1 5 6
47 if $self->has_on_close;
48
49 # return $self->get_scope_manager()->deactivate_scope( $self );
50
51 6 return $self
52
53 };
54  
55 sub DEMOLISH {
56 5 ▶ my $self = shift;
Subroutine DEMOLISH: called CC=3 SCAR=12.7
Pod undocumented
57 5 my $in_global_destruction = shift;
58
59 5 ▶ return if $self->closed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->closed 3 2 5
60
61 2 croak "Scope not programmatically closed before being demolished";
62 #
63 # below might be appreciated behaviour, but you should close yourself
64 #
65 0 ▶ $self->close( )
Branch: 1 branch
BranchTrueFalseTotal
unless $in_global_destruction 0 0 0
66 unless $in_global_destruction;
67
68 return
69 0 }
70  
71  
72  
73 BEGIN {
74 10 ▶ use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 with 'OpenTracing::Interface::Scope'
76 10 ▶ if $ENV{OPENTRACING_INTERFACE};
Subroutine BEGIN: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"OPENTRACING_INTERFACE"} 3 7 10
77 }
78  
79  
80  
81 10 1;
« Role/Span.pm ↑ Summary Role/ScopeManager.pm »