| 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.100'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | class OpenTelemetry::SDK::Resource :does(OpenTelemetry::Attributes) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | 22 | field $schema_url :param :reader //= ''; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | 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 | 27 | ▶ | sub BUILDARGS ( $class, %args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 27 | ▶ | return %args if delete $args{empty}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 23 | ▶ | my %env = map split( '=', $_, 2 ), | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
config("RESOURCE_ATTRIBUTES") // ""
MC/DC100%1/1
config("RESOURCE_ATTRIBUTES") // ""
config("RESOURCE_ATTRIBUTES")
Truth table100%2/2
A
A= config("RESOURCE_ATTRIBUTES")
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | split ',', config('RESOURCE_ATTRIBUTES') // ''; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 23 | for ( keys %env ) { | |||||||||||||||||||||||||||||||||||||||||
| 28 | 12 | ▶ | 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 | 6 | $logger->warn( | |||||||||||||||||||||||||||||||||||||||||
| 34 | 'Ignoring invalid resource attribute value in environment: must be percent-encoded', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | { key => $_ }, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | delete $env{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # Special-cased because of precedence rules | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | my $service_name = delete $env{'service.name'}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 23 | ▶ | $service_name = config('SERVICE_NAME') // $service_name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
config("SERVICE_NAME") // $service_name
MC/DC50%1/2
config("SERVICE_NAME") // $service_name
config("SERVICE_NAME")
$service_name
Truth table66%2/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 | 23 | ▶ | %{ $args{attributes} // {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"attributes"} // {}
MC/DC100%1/1
$args{"attributes"} // {}
$args{"attributes"}
Truth table100%2/2
A
A= $args{"attributes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 23 | ▶ | $args{attributes}{'service.name'} //= $service_name if $service_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"attributes"}{"service.name"} //= $service_name
MC/DC0%0/2
$args{"attributes"}{"service.name"} //= $service_name
$args{"attributes"}{"service.name"}
$service_name
Truth table66%2/3
A //= B
A= $args{"attributes"}{"service.name"}B= $service_name
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 23 | %args; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ▶ | method merge ( $new ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | return $self unless isa_OpenTelemetry_SDK_Resource $new; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | my $ours = $self->schema_url; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | my $theirs = $new->schema_url; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | if ( $ours && $theirs && $ours ne $theirs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$ours and $theirs and $ours ne $theirs
$ours and $theirs
MC/DC66%2/3
$ours and $theirs and $ours ne $theirs
$ours
$theirs
$ours ne $theirs
Truth table75%3/4
A and B and C
A= $oursB= $theirsC= $ours ne $theirs
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | $logger->warn( | |||||||||||||||||||||||||||||||||||||||||
| 76 | 'Incompatible resource schema URLs when merging resources. Ignoring new one', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | { old => $ours, new => $theirs }, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | $theirs = ''; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | ( ref $self )->new( | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | attributes => { %{ $self->attributes }, %{ $new->attributes } }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$theirs || $ours
MC/DC0%0/2
$theirs || $ours
$theirs
$ours
Truth table66%2/3
A || B
A= $theirsB= $ours
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | schema_url => $theirs || $ours, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | } | |||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | } | |||||||||||||||||||||||||||||||||||||||||