| 1 | 4 | ▶ | use Object::Pad ':experimental(init_expr)'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Represents the entity producing OpenTelemetry data | ||||||||||||||||||||||||||||||||||||||||||
| 3 | package OpenTelemetry::SDK::Resource; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | our $VERSION = '0.101'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | class OpenTelemetry::SDK::Resource :does(OpenTelemetry::Attributes) { | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use File::Basename 'basename'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use OpenTelemetry::Common 'config'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use isa 'OpenTelemetry::SDK::Resource'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | my $logger = OpenTelemetry::Common::internal_logger; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | require OpenTelemetry::SDK; # For VERSION | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | field $schema_url :param :reader //= ''; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | sub empty { shift->new( empty => 1, @_ ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: called CC=1 SCAR=0.0
Subroutine
schema_url: called CC=1 SCAR=0.0
Pod
documented
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 10 | ▶ | sub BUILDARGS ( $class, %args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=9 SCAR=28.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 10 | ▶ | return %args if delete $args{empty}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | ▶ | my %env = map split( '=', $_, 2 ), | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
config("RESOURCE_ATTRIBUTES") // ""
MC/DC0%0/1
config("RESOURCE_ATTRIBUTES") // ""
config("RESOURCE_ATTRIBUTES")
Truth table50%1/2
A
A= config("RESOURCE_ATTRIBUTES")
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | split ',', config('RESOURCE_ATTRIBUTES') // ''; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 9 | for ( keys %env ) { | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | # baggage-octet, as per https://w3c.github.io/baggage/#definition | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # ! # .. + - .. : < .. [ ] .. ~ | ||||||||||||||||||||||||||||||||||||||||||
| 31 | $env{$_} =~ /([^ \x{21} \x{23}-\x{2B} \x{2D}-\x{3A} \x{3C}-\x{5B} \x{5D}-\x{7E} ])/xx | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $logger->warn( | |||||||||||||||||||||||||||||||||||||||||
| 34 | 'Ignoring invalid resource attribute value in environment: must be percent-encoded', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | { key => $_ }, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | delete $env{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # Special-cased because of precedence rules | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | my $service_name = delete $env{'service.name'}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | ▶ | $service_name = config('SERVICE_NAME') // $service_name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
config("SERVICE_NAME") // $service_name
MC/DC0%0/2
config("SERVICE_NAME") // $service_name
config("SERVICE_NAME")
$service_name
Truth table33%1/3
A // B
A= config("SERVICE_NAME")B= $service_name
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | $args{attributes} = { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'telemetry.sdk.name' => 'opentelemetry', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'telemetry.sdk.language' => 'perl', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'telemetry.sdk.version' => $OpenTelemetry::SDK::VERSION, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'process.pid' => $$, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'process.command' => $0, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'process.executable.path' => $^X, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'process.command_args' => [ @ARGV ], | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 'process.executable.name' => basename($^X), | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 'process.runtime.name' => 'perl', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 'process.runtime.version' => "$^V", | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | %env, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 9 | ▶ | %{ $args{attributes} // {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"attributes"} // {}
MC/DC0%0/1
$args{"attributes"} // {}
$args{"attributes"}
Truth table50%1/2
A
A= $args{"attributes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | ▶ | $args{attributes}{'service.name'} //= $service_name if $service_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"attributes"}{"service.name"} //= $service_name
MC/DC0%0/2
$args{"attributes"}{"service.name"} //= $service_name
$args{"attributes"}{"service.name"}
$service_name
Truth table0%0/3
A //= B
A= $args{"attributes"}{"service.name"}B= $service_name
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 9 | %args; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | method merge ( $new ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return $self unless isa_OpenTelemetry_SDK_Resource $new; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $ours = $self->schema_url; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $theirs = $new->schema_url; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( $ours && $theirs && $ours ne $theirs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ours and $theirs and $ours ne $theirs
$ours and $theirs
MC/DC0%0/3
$ours and $theirs and $ours ne $theirs
$ours
$theirs
$ours ne $theirs
Truth table0%0/4
A and B and C
A= $oursB= $theirsC= $ours ne $theirs
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $logger->warn( | |||||||||||||||||||||||||||||||||||||||||
| 76 | 'Incompatible resource schema URLs when merging resources. Ignoring new one', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | { old => $ours, new => $theirs }, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $theirs = ''; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | ( ref $self )->new( | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | attributes => { %{ $self->attributes }, %{ $new->attributes } }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$theirs || $ours
MC/DC0%0/2
$theirs || $ours
$theirs
$ours
Truth table0%0/3
A || B
A= $theirsB= $ours
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | schema_url => $theirs || $ours, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | } | |||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | } | |||||||||||||||||||||||||||||||||||||||||