| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
165903
|
use Object::Pad ':experimental(init_expr)'; |
|
|
3
|
|
|
|
|
10493
|
|
|
|
3
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
|
|
# ABSTRACT: Represents the entity producing OpenTelemetry data |
|
3
|
|
|
|
|
|
|
package OpenTelemetry::SDK::Resource; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.028'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
771
|
class OpenTelemetry::SDK::Resource :does(OpenTelemetry::Attributes) { |
|
|
1
|
|
|
|
|
51743
|
|
|
|
1
|
|
|
|
|
171
|
|
|
8
|
3
|
|
|
3
|
|
1224
|
use File::Basename 'basename'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
384
|
|
|
9
|
3
|
|
|
3
|
|
52
|
use OpenTelemetry::Common 'config'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
186
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
936
|
use isa 'OpenTelemetry::SDK::Resource'; |
|
|
3
|
|
|
|
|
5648
|
|
|
|
3
|
|
|
|
|
32
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $logger = OpenTelemetry::Common::internal_logger; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require OpenTelemetry::SDK; # For VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
21
|
|
|
21
|
0
|
12306
|
field $schema_url :param :reader //= ''; |
|
18
|
|
|
|
|
|
|
|
|
19
|
21
|
|
|
3
|
1
|
78
|
sub empty { shift->new( empty => 1, @_ ) } |
|
|
3
|
|
|
|
|
6235
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
25
|
|
|
25
|
0
|
428269
|
sub BUILDARGS ( $class, %args ) { |
|
|
25
|
|
|
|
|
58
|
|
|
|
25
|
|
|
|
|
67
|
|
|
|
25
|
|
|
|
|
83
|
|
|
22
|
25
|
100
|
|
|
|
145
|
return %args if delete $args{empty}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
22
|
|
100
|
|
|
93
|
my %env = map split( '=', $_, 2 ), |
|
25
|
|
|
|
|
|
|
split ',', config('RESOURCE_ATTRIBUTES') // ''; |
|
26
|
|
|
|
|
|
|
|
|
27
|
22
|
|
|
|
|
924
|
for ( keys %env ) { |
|
28
|
12
|
100
|
|
|
|
59
|
if ( |
|
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
|
|
|
|
|
62
|
$logger->warn( |
|
34
|
|
|
|
|
|
|
'Ignoring invalid resource attribute value in environment: must be percent-encoded', |
|
35
|
|
|
|
|
|
|
{ key => $_ }, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
18143
|
delete $env{$_}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Special-cased because of precedence rules |
|
43
|
22
|
|
|
|
|
59
|
my $service_name = delete $env{'service.name'}; |
|
44
|
22
|
|
66
|
|
|
65
|
$service_name = config('SERVICE_NAME') // $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
|
22
|
|
100
|
|
|
1885
|
%{ $args{attributes} // {} }, |
|
|
22
|
|
|
|
|
557
|
|
|
61
|
|
|
|
|
|
|
}; |
|
62
|
|
|
|
|
|
|
|
|
63
|
22
|
100
|
66
|
|
|
104
|
$args{attributes}{'service.name'} //= $service_name if $service_name; |
|
64
|
|
|
|
|
|
|
|
|
65
|
22
|
|
|
|
|
280
|
%args; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
4
|
|
|
4
|
1
|
14154
|
method merge ( $new ) { |
|
|
4
|
|
|
|
|
17
|
|
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
7
|
|
|
69
|
4
|
50
|
|
|
|
24
|
return $self unless isa_OpenTelemetry_SDK_Resource $new; |
|
70
|
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
15
|
my $ours = $self->schema_url; |
|
72
|
4
|
|
|
|
|
11
|
my $theirs = $new->schema_url; |
|
73
|
|
|
|
|
|
|
|
|
74
|
4
|
100
|
100
|
|
|
29
|
if ( $ours && $theirs && $ours ne $theirs ) { |
|
|
|
|
66
|
|
|
|
|
|
75
|
2
|
|
|
|
|
19
|
$logger->warn( |
|
76
|
|
|
|
|
|
|
'Incompatible resource schema URLs when merging resources. Ignoring new one', |
|
77
|
|
|
|
|
|
|
{ old => $ours, new => $theirs }, |
|
78
|
|
|
|
|
|
|
); |
|
79
|
2
|
|
|
|
|
649
|
$theirs = ''; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
( ref $self )->new( |
|
83
|
4
|
|
66
|
|
|
12
|
attributes => { %{ $self->attributes }, %{ $new->attributes } }, |
|
|
4
|
|
|
|
|
17
|
|
|
|
4
|
|
|
|
|
229
|
|
|
84
|
|
|
|
|
|
|
schema_url => $theirs || $ours, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |