line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenTracing::Any; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
564
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
104
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.005'; # VERSION |
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TEAM'; # AUTHORITY |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
476
|
no indirect; |
|
2
|
|
|
|
|
1263
|
|
|
2
|
|
|
|
|
10
|
|
10
|
2
|
|
|
2
|
|
727
|
use utf8; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
10
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
OpenTracing::Any - application tracing |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use OpenTracing::Any qw($tracer); |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
my $span = $tracer->span(operation_name => 'whatever'); |
23
|
|
|
|
|
|
|
$span->add_tag(xyz => 'abc'); |
24
|
|
|
|
|
|
|
sleep 3; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
# at this point the span will be finished and have an approximate timing of ~3s |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This provides a tracer to the current package. By default it will be given the |
31
|
|
|
|
|
|
|
package variable name C<< $tracer >>, but you can override this by providing a |
32
|
|
|
|
|
|
|
different name: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use OpenTracing::Any qw($renamed_tracer_variable); |
35
|
|
|
|
|
|
|
$renamed_tracer_variable->span(...); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
See L for more details on available methods. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
See also: L. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
2
|
|
949
|
use OpenTracing; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
313
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub import { |
46
|
7
|
|
|
7
|
|
5567
|
my ($class, @args) = @_; |
47
|
7
|
100
|
|
|
|
42
|
die 'too many parameters when loading OpenTracing::Any - expects a single variable name' |
48
|
|
|
|
|
|
|
if @args > 1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Normally we'd expect the caller to provide a variable name - but if they don't, |
51
|
|
|
|
|
|
|
# '$tracer' seems as good a default as any |
52
|
6
|
|
|
|
|
13
|
my ($injected_variable) = (@args, '$tracer'); |
53
|
6
|
100
|
|
|
|
60
|
my ($bare_name) = $injected_variable =~ /^\$(\w+)$/ |
54
|
|
|
|
|
|
|
or die 'invalid injected variable name ' . $injected_variable; |
55
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
17
|
my ($pkg) = caller; |
57
|
5
|
|
|
|
|
12
|
my $fully_qualified = $pkg . '::' . $bare_name; |
58
|
|
|
|
|
|
|
{ |
59
|
2
|
|
|
2
|
|
14
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
206
|
|
|
5
|
|
|
|
|
11
|
|
60
|
|
|
|
|
|
|
# This mostly does what we'd want if we're called at compiletime before any code actually tries |
61
|
|
|
|
|
|
|
# to use the injected variable - but as soon as the compiler sees $SomeModule::tracer it'll happily |
62
|
|
|
|
|
|
|
# tell the symbol table about it and trigger this check. Thus, it's currently disabled, and |
63
|
|
|
|
|
|
|
# since Log::Any also skips the check it seems we're in good company. |
64
|
|
|
|
|
|
|
# require B; |
65
|
|
|
|
|
|
|
# die $pkg . ' already has a variable called ' . $injected_variable if B::svref_2object(\*$fully_qualified)->SV->$*; |
66
|
5
|
|
|
|
|
22
|
*{$fully_qualified} = \(OpenTracing->global_tracer()); |
|
5
|
|
|
|
|
343
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |