OpenTelemetry/Baggage.pm

filter: Statementstmt 100% 64 / 64 Branchbran 100% 2 / 2 Conditioncond 70.5% 12 / 17 MC/DCmcdc 18.1% 2 / 11 Subroutinesub 100% 14 / 14 Podpod 100% 6 / 6 totaltotal 87.7% 100 / 114 CC 17 SCAR 10.3
CC
17
Cov
94%
from_context
4.0
set
4.0
delete
4.0
CRAP 2.8
« OpenTelemetry/Common.pm ↑ Summary Log/Any/Adapter/OpenTelemetry.pm »
1 5 ▶use Object::Pad ':experimental(init_expr)';
Subroutine BEGIN: called CC=1 SCAR=0.0
2 # ABSTRACT: Records and propagates baggage in a distributed trace
3  
4 5 ▶use experimental qw( signatures lexical_subs );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use OpenTelemetry::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 my $BAGGAGE_KEY = OpenTelemetry::Context->key('baggage');
8  
9 package
10 OpenTelemetry::Baggage::Entry;
11  
12 5 our $VERSION = '0.040';
13  
14 class OpenTelemetry::Baggage::Entry {
15 12 ▶ field $value :param :reader;
Subroutine value: called CC=1 SCAR=0.0
16 field $meta :param :reader = {};
17 10 ▶}
Subroutine meta: called CC=1 SCAR=0.0
18  
19 5 package
20 OpenTelemetry::Baggage::Builder;
21  
22 5 our $VERSION = '0.040';
23  
24 class OpenTelemetry::Baggage::Builder {
25 5 field %data;
26  
27 4 ▶ method set ( $name, $value, $meta = undef ) {
Subroutine set: called CC=2 SCAR=6.9
28 4 $data{$name} = OpenTelemetry::Baggage::Entry->new(
29 value => $value,
30 meta => $meta,
31 );
32 4 $self;
33 5 }
34  
35 3 ▶ method build ( $context = undef ) {
Subroutine build: called CC=3 SCAR=11.0
36 3 ▶ $context //= OpenTelemetry::Context->current;
Condition66%2/3
$context //= "OpenTelemetry::Context"->current
l!l&&r!l&&!r
210
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table66%2/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
37 3 $context->set( $BAGGAGE_KEY => { %data } );
38 5 }
39 }
40  
41 5 package OpenTelemetry::Baggage;
42  
43 5 our $VERSION = '0.040';
44  
45 33 ▶my sub from_context ( $context = undef ) {
Subroutine from_context: called CC=4 SCAR=14.0
46 33 ▶ ( $context // OpenTelemetry::Context->current )->get($BAGGAGE_KEY) // {}
Condition80%4/5
($context // "OpenTelemetry::Context"->current)->get($BAGGAGE_KEY) // {}
l!l
1221
$context // "OpenTelemetry::Context"->current
l!l&&r!l&&!r
2904
MC/DC100%1/1
($context // "OpenTelemetry::Context"->current)->get($BAGGAGE_KEY) // {}
($context // "OpenTelemetry::Context"->current)->get($BAGGAGE_KEY)
MC/DC50%1/2
$context // "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table100%2/2
A
A= ($context // "OpenTelemetry::Context"->current)->get($BAGGAGE_KEY)
Aresult
11
00
Truth table66%2/3
A // B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
47 }
48  
49 7 ▶sub set ( $, $name, $value, $meta = undef, $context = undef ) {
Subroutine set: called CC=4 SCAR=13.9
Pod documented
50 7 ▶ $context //= OpenTelemetry::Context->current;
Condition66%2/3
$context //= "OpenTelemetry::Context"->current
l!l&&r!l&&!r
160
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table66%2/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
51  
52 7 my %new = %{ from_context $context };
53 7 $new{$name} = OpenTelemetry::Baggage::Entry->new(
54 value => $value,
55 meta => $meta,
56 );
57  
58 7 $context->set( $BAGGAGE_KEY => \%new );
59 }
60  
61 8 ▶sub get ( $, $name, $context = undef ) {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
62 8 from_context($context)->{$name}
63 }
64  
65 15 ▶sub all ( $, $context = undef ) {
Subroutine all: called CC=2 SCAR=6.9
Pod documented
66 15 %{ from_context($context) }
67 }
68  
69 3 ▶sub delete ( $, $name, $context = undef ) {
Subroutine delete: called CC=4 SCAR=13.9
Pod documented
70 3 ▶ $context //= OpenTelemetry::Context->current;
Condition66%2/3
$context //= "OpenTelemetry::Context"->current
l!l&&r!l&&!r
210
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table66%2/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
71  
72 3 my %new = %{ from_context $context };
73 3 ▶ return $context unless exists $new{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $new{$name} 2 1 3
74  
75 1 delete $new{$name};
76 1 $context->set( $BAGGAGE_KEY => \%new );
77 }
78  
79 3 ▶sub clear ( $, $context = undef ) {
Subroutine clear: called CC=3 SCAR=11.1
Pod documented
80 3 ▶ $context //= OpenTelemetry::Context->current;
Condition66%2/3
$context //= "OpenTelemetry::Context"->current
l!l&&r!l&&!r
210
MC/DC0%0/2
$context //= "OpenTelemetry::Context"->current
$context "OpenTelemetry::Context"->current
Truth table66%2/3
A //= B
A= $contextB= "OpenTelemetry::Context"->current
ABresult
1X1
011
000
81 3 $context->delete($BAGGAGE_KEY);
82 }
83  
84 3 ▶sub builder ( $ ) {
Subroutine builder: called CC=1 SCAR=0.0
Pod documented
85 3 OpenTelemetry::Baggage::Builder->new;
86 }
87  
88 5 1;
« OpenTelemetry/Common.pm ↑ Summary Log/Any/Adapter/OpenTelemetry.pm »