line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenTracing::Implementation::Test::SpanContext; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = 'v0.104.0'; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
340264
|
use Moo; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
42
|
|
6
|
5
|
|
|
5
|
|
1951
|
use Types::Standard qw/Int/; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
42
|
|
7
|
5
|
|
|
5
|
|
14733
|
use Bytes::Random::Secure qw/random_string_from/; |
|
5
|
|
|
|
|
53768
|
|
|
5
|
|
|
|
|
1290
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'OpenTracing::Role::SpanContext'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+span_id' => ( |
12
|
|
|
|
|
|
|
default => \&_random_id, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+trace_id' => ( |
16
|
|
|
|
|
|
|
default => \&_random_id, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has level => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => Int, |
22
|
|
|
|
|
|
|
default => sub { 0 }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has context_item => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
default => sub { 'default context item' }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
32
|
|
|
32
|
1
|
96
|
sub with_level { $_[0]->clone_with( level => $_[1] ) } |
31
|
|
|
|
|
|
|
|
32
|
32
|
|
|
32
|
1
|
142
|
sub with_next_level { $_[0]->with_level($_[0]->level +1) } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _random_id { |
35
|
120
|
|
|
120
|
|
36111
|
random_string_from '0123456789abcdef', 7 |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
3
|
1
|
333
|
sub with_context_item { $_[0]->clone_with(context_item => $_[1]) } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
OpenTracing::Implementation::Test::SpanContext - OpenTracing Test for SpanContext |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This is the C<SpanContext> used by L<OpenTracing::Implementation::Test>. |
51
|
|
|
|
|
|
|
The following attributes are provided on top of L<OpenTracing::Role::SpanContext>: |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 level |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The context will know how deep in the span hierarchy it is. |
56
|
|
|
|
|
|
|
The root is always level 0. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 context_item |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This attributes actually does nothing. You can use it to test any code |
61
|
|
|
|
|
|
|
which should set context attributes without having to subclass. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 level() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the depth of the span (number of parent spans) in the hierarchy. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 with_level($level) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Create a cloned object with with the new $level. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 with_next_level() |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Create a cloned object with C<level> increased by one. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 with_context_item($new_item) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Create a cloned object with $new_item as C<context_item>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Szymon Nieznanski <snieznanski@perceptyx.com> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
'Test::OpenTracing::Integration' |
92
|
|
|
|
|
|
|
is Copyright (C) 2019 .. 2020, Perceptyx Inc |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
95
|
|
|
|
|
|
|
the terms of the Artistic License 2.0. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This package is distributed in the hope that it will be useful, but it is |
98
|
|
|
|
|
|
|
provided "as is" and without any express or implied warranties. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
For details, see the full text of the license in the file LICENSE. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |