Role/ScopeManager.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 97.8% 46 / 47 CC 3 SCAR 4.4
CC
3
Cov
97%
activate_span
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Role/Span.pm ↑ Summary Role/GlobalTracer.pm »
1 package OpenTracing::Role::ScopeManager;
2  
3 12 our $VERSION = 'v0.86.1';
4  
5 12 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use MooX::Should;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use OpenTracing::Types qw/Scope Span assert_Scope/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use Role::Declare::Should;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Types::Standard qw/Bool CodeRef Dict Maybe/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # The chosen design is to have only 1 active scope and use callback to change
14 # what the 'previous' scope would be when we close a scope.
15 #
16 # An other design could be building a stack, using 'push/pop' to keep track of
17 # which one to activate on close.
18 #
19 12 has active_scope => (
20 is => 'rwp',
21 should => Scope,
22 init_arg => undef,
23 reader => 'get_active_scope',
24 writer => 'set_active_scope',
25 );
26  
27 3 ▶sub activate_span {
Subroutine activate_span: called CC=3 SCAR=11.0
Pod documented
28 3 my $self = shift;
29 3 ▶ my $span = shift or croak "Missing OpenTracing Span";
Branch: 1 branch
BranchTrueFalseTotal
my $span = shift() or croak("Missing OpenTracing Span") 3 0 3
30
31 3 my $options = { @_ };
32
33 my $finish_span_on_close =
34 exists( $options->{ finish_span_on_close } ) ?
35 !! delete $options->{ finish_span_on_close }
36 : !undef
37 3 ▶ ; # use 'truthness' of param if provided, or set to 'true' otherwise
Branch: 1 branch
BranchTrueFalseTotal
exists $options->{'finish_span_on_close'} ? : 1 2 3
38
39 3 my $scope = $self->build_scope(
40 span => $span,
41 finish_span_on_close => $finish_span_on_close,
42 %$options,
43 );
44
45 3 $self->set_active_scope( $scope );
46
47 3 return $scope
48 }
49  
50 instance_method build_scope (
51 Span :$span,
52 Bool :$finish_span_on_close
53 12 ▶) :Return ( Scope ) { };
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55  
56  
57 12 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
58 # use Role::Tiny::With;
59 12 with 'OpenTracing::Interface::ScopeManager'
60 }
61  
62 12 1;
« Role/Span.pm ↑ Summary Role/GlobalTracer.pm »