line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenTracing::Types; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
OpenTracing::Types - Type constraints for checking Interfaces |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.19'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use OpenTracing::Types qw/Span/; |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# imports the 'Span' Type |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Types::Standard qw/Maybe/; |
24
|
|
|
|
|
|
|
use Types::Common::Numeric qw/PositiveOrZeroNum/; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Function::Parameters; |
27
|
|
|
|
|
|
|
use Function::Return; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# create a subroutine with some fancy type checks |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
sub time_gap (Span $span1, Span $span2) :Return Maybe[PositiveOrZeroNum] { |
32
|
|
|
|
|
|
|
return unless $span1->finish_time and $span2->start_time; |
33
|
|
|
|
|
|
|
return $span2->start_time - $span1->finish_time |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This library of L<Type::Tiny> type constraints provide Duck Type checks for all |
39
|
|
|
|
|
|
|
common elements that conform L<OpenTracing::Interface> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
See L<Type::Library/"Export"> about the various ways to import types an related |
42
|
|
|
|
|
|
|
methods. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
25
|
|
|
25
|
|
884844
|
use Type::Library -base; |
|
25
|
|
|
|
|
224678
|
|
|
25
|
|
|
|
|
205
|
|
47
|
25
|
|
|
25
|
|
10427
|
use Type::Utils qw/duck_type/; |
|
25
|
|
|
|
|
36528
|
|
|
25
|
|
|
|
|
198
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Dear developer, for the sake of testing, please DO NOT just copy paste the |
50
|
|
|
|
|
|
|
# methods from the `OpenTracing::Types` file. If I wanted to just |
51
|
|
|
|
|
|
|
# check that the `duck_type` utility from `Type::Tiny` would work, I would have |
52
|
|
|
|
|
|
|
# not needed this test. |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# This test is to ensure that what is written in the POD files is indeed what |
55
|
|
|
|
|
|
|
# the Types library is doing. |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
# The OpenTracing::Interface::*.pod files are leading, not the code. |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
use constant { |
60
|
25
|
|
|
|
|
5259
|
REQUIRED_METHODS_FOR_CONTEXT_REFERENCE => [ qw( |
61
|
|
|
|
|
|
|
new_child_of |
62
|
|
|
|
|
|
|
new_follows_from |
63
|
|
|
|
|
|
|
get_referenced_context |
64
|
|
|
|
|
|
|
type_is_child_of |
65
|
|
|
|
|
|
|
type_is_follows_from |
66
|
|
|
|
|
|
|
) ], |
67
|
|
|
|
|
|
|
REQUIRED_METHODS_FOR_SCOPE => [ qw( |
68
|
|
|
|
|
|
|
close |
69
|
|
|
|
|
|
|
get_span |
70
|
|
|
|
|
|
|
) ], |
71
|
|
|
|
|
|
|
REQUIRED_METHODS_FOR_SCOPE_MANAGER => [ qw( |
72
|
|
|
|
|
|
|
activate_span |
73
|
|
|
|
|
|
|
get_active_scope |
74
|
|
|
|
|
|
|
) ], |
75
|
|
|
|
|
|
|
REQUIRED_METHODS_FOR_SPAN => [ qw( |
76
|
|
|
|
|
|
|
get_context |
77
|
|
|
|
|
|
|
overwrite_operation_name |
78
|
|
|
|
|
|
|
finish |
79
|
|
|
|
|
|
|
set_tag |
80
|
|
|
|
|
|
|
log_data |
81
|
|
|
|
|
|
|
set_baggage_item |
82
|
|
|
|
|
|
|
get_baggage_item |
83
|
|
|
|
|
|
|
) ], |
84
|
|
|
|
|
|
|
REQUIRED_METHODS_FOR_SPAN_CONTEXT => [ qw( |
85
|
|
|
|
|
|
|
get_baggage_item |
86
|
|
|
|
|
|
|
with_baggage_item |
87
|
|
|
|
|
|
|
) ], |
88
|
|
|
|
|
|
|
REQUIRED_METHODS_FOR_TRACER => [ qw( |
89
|
|
|
|
|
|
|
get_scope_manager |
90
|
|
|
|
|
|
|
get_active_span |
91
|
|
|
|
|
|
|
start_active_span |
92
|
|
|
|
|
|
|
start_span |
93
|
|
|
|
|
|
|
inject_context |
94
|
|
|
|
|
|
|
extract_context |
95
|
|
|
|
|
|
|
) ], |
96
|
25
|
|
|
25
|
|
15783
|
}; |
|
25
|
|
|
|
|
62
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# XXX DO NOT COPY PASTE FROM CODE, READ THE POD |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
duck_type ContextReference => REQUIRED_METHODS_FOR_CONTEXT_REFERENCE; |
101
|
|
|
|
|
|
|
duck_type Scope => REQUIRED_METHODS_FOR_SCOPE; |
102
|
|
|
|
|
|
|
duck_type ScopeManager => REQUIRED_METHODS_FOR_SCOPE_MANAGER; |
103
|
|
|
|
|
|
|
duck_type Span => REQUIRED_METHODS_FOR_SPAN; |
104
|
|
|
|
|
|
|
duck_type SpanContext => REQUIRED_METHODS_FOR_SPAN_CONTEXT; |
105
|
|
|
|
|
|
|
duck_type Tracer => REQUIRED_METHODS_FOR_TRACER; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 TYPES |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The following Duck Types are being defined with the mentioned required methods: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 C<< ContextReference >> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item C<< new_child_of >> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item C<< new_follows_from >> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item C<< get_referenced_context >> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item C<< type_is_child_of >> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item C<< type_is_follows_from >> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
See also L<OpenTracing::Interface::ContextReference/"INSTANCE METHODS"> |
134
|
|
|
|
|
|
|
and L<OpenTracing::Interface::ContextReference/"CONSTRUCTOR METHODS">. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 C<< Scope >> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item C<< close >> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item C<< get_span >> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
See also L<OpenTracing::Interface::Scope/"INSTANCE METHODS">. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 C<< ScopeManager >> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item C<< activate_span >> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item C<< get_active_scope >> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
See also L<OpenTracing::Interface::ScopeManager/"INSTANCE METHODS">. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 C<< Span >> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item C<< get_context >> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item C<< overwrite_operation_name >> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item C<< finish >> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item C<< set_tag >> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item C<< log_data >> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item C<< set_baggage_item >> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item C<< get_baggage_item >> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
See also L<OpenTracing::Interface::Span/"INSTANCE METHODS">. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 C<< SpanContext >> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=over |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item C<< get_baggage_item >> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item C<< with_baggage_item >> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
See also L<OpenTracing::Interface::SpanContext/"INSTANCE METHODS">. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 C<< Tracer >> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=over |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item C<< get_scope_manager >> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item C<< get_active_span >> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item C<< start_active_span >> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item C<< start_span >> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item C<< inject_context >> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item C<< extract_context >> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=back |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
See also L<OpenTracing::Interface::Tracer/"INSTANCE METHODS">. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 AUTHOR |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Theo van Hoesel <tvanhoesel@perceptyx.com> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
'OpenTracing Types' is Copyright (C) 2020, Perceptyx Inc |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
238
|
|
|
|
|
|
|
the terms of the Artistic License 2.0. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful, but it is |
241
|
|
|
|
|
|
|
provided "as is" and without any express or implied warranties. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
For details, see the full text of the license in the file LICENSE. |