Implementation.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 61.1% 11 / 18 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 14 / 14 Podpod 66.6% 4 / 6 totaltotal 85.0% 74 / 87 SCAR 24.3
CC
11
Cov
86%
OT_DEBUG
5.3
OT_IMPLEMENTATION_NAME
3.1
_build_tracer
3.0
CRAP 11.3
↑ Summary Implementation/Interface/Bootstrap.pm »
1 package OpenTracing::Implementation;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = 'v0.33.0';
7  
8 sub OT_IMPLEMENTATION_NAME {
9 exists $ENV{ PERL_OPENTRACING_IMPLEMENTATION } ?
10 $ENV{ PERL_OPENTRACING_IMPLEMENTATION } :
11 exists $ENV{ OPENTRACING_IMPLEMENTATION } ?
12 $ENV{ OPENTRACING_IMPLEMENTATION } :
13 3 ▶ 'NoOp'
Subroutine OT_IMPLEMENTATION_NAME: called CC=3 SCAR=11.2
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
exists $ENV{'PERL_OPENTRACING_IMPLEMENTATION'} ? : 0 3 3
exists $ENV{'OPENTRACING_IMPLEMENTATION'} ? : 2 1 3
14 }
15  
16 sub OT_DEBUG {
17 exists $ENV{ PERL_OPENTRACING_DEBUG } ?
18 $ENV{ PERL_OPENTRACING_DEBUG } :
19 exists $ENV{ OPENTRACING_DEBUG } ?
20 $ENV{ OPENTRACING_DEBUG } :
21 exists $ENV{ DEBUG } ?
22 $ENV{ DEBUG } :
23 undef
24 5 ▶}
Subroutine OT_DEBUG: called CC=4 SCAR=16.6
Pod undocumented
Branch: 3 branches
BranchTrueFalseTotal
exists $ENV{'PERL_OPENTRACING_DEBUG'} ? : 0 5 5
exists $ENV{'OPENTRACING_DEBUG'} ? : 0 5 5
exists $ENV{'DEBUG'} ? : 0 5 5
25 #
26 # it was meant to be a constant, but during test, these seem to be dynamic
27  
28  
29  
30 3 ▶use OpenTracing::GlobalTracer;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 3 our @CARP_NOT;
36  
37 sub import {
38 3 ▶ my $package = shift;
Subroutine import: called CC=2 SCAR=8.1
39 3 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 3 0 3
40
41 0 __PACKAGE__->bootstrap_global_tracer( @_ )
42 }
43  
44 1 ▶sub bootstrap_tracer { shift->_build_tracer( @_ ) }
Subroutine bootstrap_tracer: called CC=1 SCAR=0.0
Pod documented
45  
46 2 ▶sub bootstrap_default_tracer { shift->_build_tracer( undef, @_ ) }
Subroutine bootstrap_default_tracer: called CC=1 SCAR=0.0
Pod documented
47  
48 sub bootstrap_global_tracer {
49 1 ▶ OpenTracing::GlobalTracer->set_global_tracer( shift->_build_tracer( @_ ) );
Subroutine bootstrap_global_tracer: called CC=1 SCAR=0.0
Pod documented
50 1 return OpenTracing::GlobalTracer->get_global_tracer
51 }
52  
53 sub bootstrap_global_default_tracer {
54 1 ▶ OpenTracing::GlobalTracer->set_global_tracer( shift->_build_tracer( undef, @_ ) );
Subroutine bootstrap_global_default_tracer: called CC=1 SCAR=0.0
Pod documented
55 1 return OpenTracing::GlobalTracer->get_global_tracer
56 }
57  
58 # _build_tracer
59 #
60 # passing undef as implementation name will cause to use the $ENV
61 #
62 sub _build_tracer {
63 5 ▶ my $package = shift;
Subroutine _build_tracer: called CC=3 SCAR=11.1
64 5 my $implementation_name = shift;
65 5 my @implementation_args = @_;
66
67 5 my $implementation_class =
68 __PACKAGE__->_get_implementation_class( $implementation_name );
69
70 5 ▶ carp "Loading implementation $implementation_class"
Branch: 1 branch
BranchTrueFalseTotal
if OT_DEBUG() 0 5 5
71 if OT_DEBUG;
72
73 5 load $implementation_class;
74
75 5 eval { load $implementation_class };
76 5 ▶ croak "GlobalTracer can't load implementation [$implementation_class]"
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 5 5
77 if $@;
78
79 5 my $tracer = $implementation_class->bootstrap_tracer( @implementation_args);
80
81 5 return $tracer
82 }
83  
84 sub _get_implementation_class {
85 5 ▶ my $class = shift;
Subroutine _get_implementation_class: called CC=3 SCAR=11.0
86 5 ▶ my $implementation_name = shift // OT_IMPLEMENTATION_NAME;
Condition66%2/3
shift() // OT_IMPLEMENTATION_NAME()
l!l&&r!l&&!r
230
MC/DC0%0/2
shift() // OT_IMPLEMENTATION_NAME()
shift() OT_IMPLEMENTATION_NAME()
Truth table66%2/3
A // B
A= shift()B= OT_IMPLEMENTATION_NAME()
ABresult
1X1
011
000
87
88 5 ▶ my $implementation_class = substr( $implementation_name, 0, 1) eq '+' ?
Branch: 1 branch
BranchTrueFalseTotal
substr($implementation_name, 0, 1) eq '+' ? : 4 1 5
89 substr( $implementation_name, 1 )
90 :
91 'OpenTracing::Implementation::' . $implementation_name;
92
93 5 return $implementation_class
94 }
95  
96 3 1;
↑ Summary Implementation/Interface/Bootstrap.pm »