OpenTelemetry/Propagator/Composite.pm

filter: Statementstmt 100% 57 / 57 Branchbran 100% 2 / 2 Conditioncond 50.0% 11 / 22 MC/DCmcdc 15.3% 2 / 13 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 75.9% 82 / 108 CC 16 SCAR 15.8
CC
16
Cov
86%
inject
6.5
extract
6.5
BUILDARGS
6.2
CRAP 4.9
« OpenTelemetry/Propagator/Baggage.pm ↑ Summary OpenTelemetry/Propagator/TraceContext.pm »
1 1 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 # ABSTRACT: A composite context propagator for OpenTelemetry
3  
4 package OpenTelemetry::Propagator::Composite;
5  
6 1 our $VERSION = '0.040';
7  
8 1 ▶class OpenTelemetry::Propagator::Composite :does(OpenTelemetry::Propagator) {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶ use List::Util qw( uniq first );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶ use OpenTelemetry::Propagator::TextMap;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶ use OpenTelemetry::X;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶ use OpenTelemetry::Common ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my $logger = OpenTelemetry::Common::internal_logger;
15  
16 1 field @injectors;
17 1 field @extractors;
18  
19 3 ▶ sub BUILDARGS ( $, @args ) {
Subroutine BUILDARGS: called CC=6 SCAR=18.2
Pod undocumented
20 3 my %return = (
21 extractors => [ grep $_->can('extract'), @args ],
22 injectors => [ grep $_->can('inject'), @args ],
23 );
24  
25 $logger->warnf('No suitable propagators when constructing Composite propagator')
26 if @args
27 2 ▶ && ! @{ $return{extractors} // [] }
Condition50%1/2
$return{"extractors"} // []
l!l
20
MC/DC0%0/1
$return{"extractors"} // []
$return{"extractors"}
Truth table50%1/2
A
A= $return{"extractors"}
Aresult
11
00
28 3 ▶ && ! @{ $return{injectors} // [] };
Branch: 1 branch
BranchTrueFalseTotal
if @args and not @{$return{"extractors"} // [];} and not @{$return{"injectors"} // [];} 1 2 3
Condition75%6/8
@args and not @{$return{"extractors"} // [];} and not @{$return{"injectors"} // [];}
!ll&&!rl&&r
201
@args and not @{$return{"extractors"} // [];}
!ll&&!rl&&r
111
$return{"injectors"} // []
l!l
10
MC/DC66%2/3
@args and not @{$return{"extractors"} // [];} and not @{$return{"injectors"} // [];}
@args not @{$return{"extractors"} // [];} not @{$return{"injectors"} // [];}
MC/DC0%0/1
$return{"injectors"} // []
$return{"injectors"}
Truth table75%3/4
A and not(B) and not(C)
A= @argsB= not @{$return{"extractors"} // [];}C= not @{$return{"injectors"} // [];}
ABCresult
0XX0
10X0
1100
1111
Truth table50%1/2
A
A= $return{"injectors"}
Aresult
11
00
29  
30 3 %return;
31 }
32  
33 ADJUSTPARAMS ($params) {
34 @injectors = @{ delete $params->{injectors} // [] };
35 @extractors = @{ delete $params->{extractors} // [] };
36 }
37  
38 1 ▶ method inject (
Subroutine inject: called CC=6 SCAR=18.7
Pod undocumented
39 1 $carrier,
40 1 $context = undef,
41 $setter = undef
42 1 ) {
43 1 ▶ $context //= OpenTelemetry::Context->current;
Condition33%1/3
$context //= "OpenTelemetry::Context"->current
l!l&&r!l&&!r
100
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table33%1/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
44 1 ▶ $setter //= OpenTelemetry::Propagator::TextMap::SETTER;
Condition33%1/3
$setter //= OpenTelemetry::Propagator::TextMap::SETTER()
l!l&&r!l&&!r
010
MC/DC0%0/2
$setter //= OpenTelemetry::Propagator::TextMap::SETTER()
$setter OpenTelemetry::Propagator::TextMap::SETTER()
Truth table33%1/3
A //= B
A= $setterB= OpenTelemetry::Propagator::TextMap::SETTER()
ABresult
1X1
011
000
45  
46 1 $_->inject( $carrier, $context, $setter ) for @injectors;
47 1 return $self;
48 1 }
49  
50 1 ▶ method extract (
Subroutine extract: called CC=6 SCAR=18.7
Pod undocumented
51 1 $carrier,
52 1 $context = undef,
53 $getter = undef
54 1 ) {
55 1 ▶ $context //= OpenTelemetry::Context->current;
Condition33%1/3
$context //= "OpenTelemetry::Context"->current
l!l&&r!l&&!r
010
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table33%1/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
56 1 ▶ $getter //= OpenTelemetry::Propagator::TextMap::GETTER;
Condition33%1/3
$getter //= OpenTelemetry::Propagator::TextMap::GETTER()
l!l&&r!l&&!r
010
MC/DC0%0/2
$getter //= OpenTelemetry::Propagator::TextMap::GETTER()
$getter OpenTelemetry::Propagator::TextMap::GETTER()
Truth table33%1/3
A //= B
A= $getterB= OpenTelemetry::Propagator::TextMap::GETTER()
ABresult
1X1
011
000
57  
58 1 my $ctx = $context;
59 1 $ctx = $_->extract( $carrier, $ctx, $getter ) for @extractors;
60 1 return $ctx;
61 1 }
62  
63 1 ▶ method keys () {
Subroutine keys: called CC=1 SCAR=0.0
Pod undocumented
64 1 uniq map $_->keys, @injectors, @extractors
65 1 }
66 1 }
« OpenTelemetry/Propagator/Baggage.pm ↑ Summary OpenTelemetry/Propagator/TraceContext.pm »