line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Redis::OpenTracing; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
2096773
|
use strict; |
|
6
|
|
|
|
|
54
|
|
|
6
|
|
|
|
|
192
|
|
4
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
164
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1634
|
use syntax 'maybe'; |
|
6
|
|
|
|
|
88110
|
|
|
6
|
|
|
|
|
32
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v0.2.3'; |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
17052
|
use Moo; |
|
6
|
|
|
|
|
27817
|
|
|
6
|
|
|
|
|
63
|
|
11
|
6
|
|
|
6
|
|
9089
|
use Types::Standard qw/HashRef Maybe Object Str Value is_Str/; |
|
6
|
|
|
|
|
477377
|
|
|
6
|
|
|
|
|
66
|
|
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
19565
|
use OpenTracing::AutoScope; |
|
6
|
|
|
|
|
72961
|
|
|
6
|
|
|
|
|
202
|
|
14
|
6
|
|
|
6
|
|
41
|
use Scalar::Util 'blessed'; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
2116
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'redis' => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Object, # beyond current scope to detect if it is a Redis like client |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has '_redis_client_class_name' => ( |
27
|
|
|
|
|
|
|
is => 'lazy', |
28
|
|
|
|
|
|
|
isa => Str, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _build__redis_client_class_name { |
32
|
4
|
|
|
4
|
|
164
|
blessed( shift->redis ) |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _operation_name { |
38
|
12
|
|
|
12
|
|
43
|
my ( $self, $method_name ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
12
|
|
|
|
|
201
|
return $self->_redis_client_class_name . '::' . $method_name; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has 'tags' => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
isa => HashRef[Value], |
48
|
|
|
|
|
|
|
default => sub { {} }, # an empty HashRef |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $AUTOLOAD; # keep 'use strict' happy |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub AUTOLOAD { |
56
|
12
|
|
|
12
|
|
30445
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
12
|
|
|
|
|
24
|
my $method_call = do { $_ = $AUTOLOAD; s/.*:://; $_ }; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
80
|
|
|
12
|
|
|
|
|
36
|
|
59
|
12
|
|
|
|
|
236
|
my $component_name = $self->_redis_client_class_name( ); |
60
|
12
|
|
|
|
|
256
|
my $db_statement = uc($method_call); |
61
|
12
|
|
|
|
|
36
|
my $operation_name = $self->_operation_name( $method_call ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $method_wrap = sub { |
64
|
13
|
|
|
13
|
|
753
|
my $self = shift; |
65
|
|
|
|
|
|
|
OpenTracing::AutoScope->start_guarded_span( |
66
|
|
|
|
|
|
|
$operation_name, |
67
|
|
|
|
|
|
|
tags => { |
68
|
|
|
|
|
|
|
'component' => $component_name, |
69
|
|
|
|
|
|
|
|
70
|
13
|
|
|
|
|
23
|
%{ $self->tags( ) }, |
|
13
|
|
|
|
|
145
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
'db.statement' => $db_statement, |
73
|
|
|
|
|
|
|
'db.type' => 'redis', |
74
|
|
|
|
|
|
|
'span.kind' => 'client', |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
}, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
13
|
|
|
|
|
28296
|
return $self->redis->$method_call(@_); |
80
|
12
|
|
|
|
|
145
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Save this method for future calls |
83
|
6
|
|
|
6
|
|
53
|
no strict 'refs'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
518
|
|
84
|
12
|
|
|
|
|
45
|
*$AUTOLOAD = $method_wrap; |
85
|
|
|
|
|
|
|
|
86
|
12
|
|
|
|
|
30
|
goto $method_wrap; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
0
|
|
|
sub DESTROY { } # we don't want this to be dispatched |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |