| 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"} // []
MC/DC0%0/1
$return{"extractors"} // []
$return{"extractors"}
Truth table50%1/2
A
A= $return{"extractors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | && ! @{ $return{injectors} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%6/8
@args and not @{$return{"extractors"} // [];} and not @{$return{"injectors"} // [];}
@args and not @{$return{"extractors"} // [];}
$return{"injectors"} // []
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"} // [];}
Truth table50%1/2
A
A= $return{"injectors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context
"OpenTelemetry::Context"->current
Truth table33%1/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | $setter //= OpenTelemetry::Propagator::TextMap::SETTER; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$setter //= OpenTelemetry::Propagator::TextMap::SETTER()
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()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context
"OpenTelemetry::Context"->current
Truth table33%1/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | $getter //= OpenTelemetry::Propagator::TextMap::GETTER; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$getter //= OpenTelemetry::Propagator::TextMap::GETTER()
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()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||