line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenTracing::Role::ScopeManager; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = 'v0.86.0'; |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
513832
|
use Moo::Role; |
|
12
|
|
|
|
|
18607
|
|
|
12
|
|
|
|
|
73
|
|
6
|
12
|
|
|
12
|
|
6097
|
use MooX::Should; |
|
12
|
|
|
|
|
13850
|
|
|
12
|
|
|
|
|
92
|
|
7
|
|
|
|
|
|
|
|
8
|
16
|
|
|
12
|
|
1412
|
use Carp; |
|
14
|
|
|
|
|
114
|
|
|
12
|
|
|
|
|
827
|
|
9
|
12
|
|
|
12
|
|
1476
|
use OpenTracing::Types qw/Scope Span assert_Scope/; |
|
12
|
|
|
|
|
140539
|
|
|
12
|
|
|
|
|
120
|
|
10
|
12
|
|
|
12
|
|
12296
|
use Role::Declare::Should; |
|
12
|
|
|
|
|
3644
|
|
|
12
|
|
|
|
|
80
|
|
11
|
12
|
|
|
12
|
|
374507
|
use Types::Standard qw/Bool CodeRef Dict Maybe/; |
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
95
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# The chosen design is to have only 1 active scope and use callback to change |
14
|
|
|
|
|
|
|
# what the 'previous' scope would be when we close a scope. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# An other design could be building a stack, using 'push/pop' to keep track of |
17
|
|
|
|
|
|
|
# which one to activate on close. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
has active_scope => ( |
20
|
|
|
|
|
|
|
is => 'rwp', |
21
|
|
|
|
|
|
|
should => Scope, |
22
|
|
|
|
|
|
|
init_arg => undef, |
23
|
|
|
|
|
|
|
reader => 'get_active_scope', |
24
|
|
|
|
|
|
|
writer => 'set_active_scope', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub activate_span { |
28
|
3
|
|
|
3
|
1
|
12
|
my $self = shift; |
29
|
3
|
|
|
|
|
15
|
my $span = shift or croak "Missing OpenTracing Span"; |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
407
|
my $options = { @_ }; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $finish_span_on_close = |
34
|
|
|
|
|
|
|
exists( $options->{ finish_span_on_close } ) ? |
35
|
|
|
|
|
|
|
!! delete $options->{ finish_span_on_close } |
36
|
|
|
|
|
|
|
: !undef |
37
|
3
|
|
|
|
|
136
|
; # use 'truthness' of param if provided, or set to 'true' otherwise |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $scope = $self->build_scope( |
40
|
|
|
|
|
|
|
span => $span, |
41
|
|
|
|
|
|
|
finish_span_on_close => $finish_span_on_close, |
42
|
|
|
|
|
|
|
%$options, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->set_active_scope( $scope ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return $scope |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
instance_method build_scope ( |
51
|
|
|
|
|
|
|
Span :$span, |
52
|
|
|
|
|
|
|
Bool :$finish_span_on_close |
53
|
12
|
50
|
33
|
12
|
|
35813
|
) :Return ( Scope ) { }; |
|
12
|
50
|
|
|
|
63
|
|
|
12
|
100
|
|
|
|
91
|
|
|
4
|
100
|
|
|
|
9258
|
|
|
4
|
50
|
|
|
|
25
|
|
|
4
|
50
|
|
|
|
9
|
|
|
4
|
100
|
|
|
|
13
|
|
|
4
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
10
|
|
|
12
|
|
|
|
|
10142
|
|
|
3
|
|
|
|
|
23949
|
|
|
3
|
|
|
|
|
14
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
BEGIN { |
58
|
|
|
|
|
|
|
# use Role::Tiny::With; |
59
|
3
|
|
|
12
|
|
8
|
with 'OpenTracing::Interface::ScopeManager' |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |