line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenTracing::Role::ScopeManager; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = 'v0.85.0'; |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
493846
|
use Moo::Role; |
|
12
|
|
|
|
|
17737
|
|
|
12
|
|
|
|
|
85
|
|
6
|
12
|
|
|
12
|
|
6069
|
use MooX::Should; |
|
12
|
|
|
|
|
13993
|
|
|
16
|
|
|
|
|
247
|
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
12
|
|
1421
|
use Carp; |
|
12
|
|
|
|
|
30
|
|
|
12
|
|
|
|
|
886
|
|
9
|
12
|
|
|
12
|
|
1375
|
use OpenTracing::Types qw/Scope Span assert_Scope/; |
|
12
|
|
|
|
|
129123
|
|
|
12
|
|
|
|
|
135
|
|
10
|
12
|
|
|
12
|
|
12710
|
use Role::Declare::Should; |
|
12
|
|
|
|
|
3585
|
|
|
12
|
|
|
|
|
100
|
|
11
|
12
|
|
|
12
|
|
448554
|
use Types::Standard qw/Bool CodeRef Dict Maybe/; |
|
12
|
|
|
|
|
32
|
|
|
12
|
|
|
|
|
101
|
|
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
|
16
|
my $self = shift; |
29
|
3
|
|
|
|
|
18
|
my $span = shift or croak "Missing OpenTracing Span"; |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
474
|
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
|
|
|
|
|
148
|
; # 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
|
|
18798
|
) :Return ( Scope ) { }; |
|
12
|
50
|
|
|
|
107
|
|
|
12
|
100
|
|
|
|
84
|
|
|
4
|
100
|
|
|
|
9994
|
|
|
4
|
50
|
|
|
|
30
|
|
|
4
|
50
|
|
|
|
12
|
|
|
4
|
100
|
|
|
|
15
|
|
|
4
|
|
|
|
|
21
|
|
|
3
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
16
|
|
|
12
|
|
|
|
|
10515
|
|
|
3
|
|
|
|
|
24307
|
|
|
3
|
|
|
|
|
15
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
BEGIN { |
58
|
|
|
|
|
|
|
# use Role::Tiny::With; |
59
|
3
|
|
|
12
|
|
11
|
with 'OpenTracing::Interface::ScopeManager' |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |