Implementation.pm

filter: Statementstmt 46.5% 20 / 43 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 54.5% 6 / 11 Podpod 100% 3 / 3 totaltotal 42.8% 30 / 70 CC 7 SCAR 20.5
CC
7
Cov
38%
_get_implementation_class
20.0
_build_tracer
12.0
import
2.3
CRAP 7.7
↑ Summary Implementation/Interface/Bootstrap.pm »
1 package OpenTracing::Implementation;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = 'v0.32.0';
7  
8 2 ▶use OpenTracing::GlobalTracer;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our @CARP_NOT;
14  
15 sub import {
16 2 ▶ my $package = shift;
Subroutine import: called CC=2 SCAR=8.1
17 2 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 2 0 2
18
19 0 __PACKAGE__->bootstrap_global_tracer( @_ )
20 }
21  
22 0 ▶sub bootstrap_tracer { shift->_build_tracer( @_ ) }
Subroutine bootstrap_tracer: not called CC=1 SCAR=6.9
Pod documented
23  
24 0 ▶sub bootstrap_default_tracer { shift->_build_tracer( undef, @_ ) }
Subroutine bootstrap_default_tracer: not called CC=1 SCAR=6.9
Pod documented
25  
26 sub bootstrap_global_tracer {
27 0 ▶ my $package = shift;
Subroutine bootstrap_global_tracer: not called CC=1 SCAR=6.9
Pod documented
28 0 my $tracer = $package->_build_tracer( @_ );
29
30 0 OpenTracing::GlobalTracer->set_global_tracer( $tracer );
31
32 0 return OpenTracing::GlobalTracer->get_global_tracer
33 }
34  
35 # _build_tracer
36 #
37 # passing undef as implementation name will cause to use the $ENV
38 #
39 sub _build_tracer {
40 0 ▶ my $package = shift;
Subroutine _build_tracer: not called CC=3 SCAR=24.8
41 0 my $implementation_name = shift;
42 0 my @implementation_args = @_;
43
44 0 my $implementation_class =
45 __PACKAGE__->_get_implementation_class( $implementation_name );
46
47 carp "Loading implementation $implementation_class"
48 0 ▶ if $ENV{OPENTRACING_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"OPENTRACING_DEBUG"} 0 0 0
49
50 0 load $implementation_class;
51
52 0 eval { load $implementation_class };
53 0 ▶ croak "GlobalTracer can't load implementation [$implementation_class]"
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
54 if $@;
55
56 0 my $tracer = $implementation_class->bootstrap_tracer( @implementation_args);
57
58 0 return $tracer
59 }
60  
61 sub _get_implementation_class {
62 0 ▶ my $class = shift;
Subroutine _get_implementation_class: not called CC=4 SCAR=30.0
63 0 my $implementation_name = shift;
64
65 0 ▶ $implementation_name = $ENV{OPENTRACING_IMPLEMENTATION} || 'NoOp'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $implementation_name 0 0 0
Condition0%0/2
$ENV{'OPENTRACING_IMPLEMENTATION'} || 'NoOp'
l!l
00
MC/DC0%0/1
$ENV{'OPENTRACING_IMPLEMENTATION'} || 'NoOp'
$ENV{'OPENTRACING_IMPLEMENTATION'}
Truth table0%0/2
A
A= $ENV{'OPENTRACING_IMPLEMENTATION'}
Aresult
11
00
66 unless defined $implementation_name;
67  
68 0 ▶ my $implementation_class = substr( $implementation_name, 0, 1) eq '+' ?
Branch: 1 branch
BranchTrueFalseTotal
substr($implementation_name, 0, 1) eq '+' ? : 0 0 0
69 substr( $implementation_name, 1 )
70 :
71 'OpenTracing::Implementation::' . $implementation_name;
72
73 0 return $implementation_class
74 }
75  
76 2 1;
↑ Summary Implementation/Interface/Bootstrap.pm »