line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenTracing::Implementation::DataDog::Tracer; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
562967
|
use strict; |
|
4
|
|
|
|
|
43
|
|
|
4
|
|
|
|
|
128
|
|
4
|
4
|
|
|
4
|
|
33
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
198
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 'v0.40.0.7-TRIAL'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
OpenTracing::Implementation::DataDog::Tracer - Keep track of traces |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use aliased 'OpenTracing::Implementation::DataDog::Tracer'; |
16
|
|
|
|
|
|
|
use aliased 'OpenTracing::Implementation::DataDog::Agent'; |
17
|
|
|
|
|
|
|
use aliased 'OpenTracing::Implementation::DataDog::ScopeManager'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $TRACER = Tracer->new( |
20
|
|
|
|
|
|
|
agent => Agent->new(), |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
and later |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub foo { |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $scope = $TRACER->start_active_span( 'Operation Name' => %options ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
... |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$scope->close; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return $foo |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
4
|
|
1532
|
use syntax 'maybe'; |
|
4
|
|
|
|
|
77758
|
|
|
4
|
|
|
|
|
35
|
|
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
4
|
|
13664
|
use Moo; |
|
4
|
|
|
|
|
22805
|
|
|
4
|
|
|
|
|
28
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
with 'OpenTracing::Role::Tracer'; |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
4
|
|
6122
|
use aliased 'OpenTracing::Implementation::DataDog::Agent'; |
|
4
|
|
|
|
|
1594
|
|
|
4
|
|
|
|
|
37
|
|
45
|
4
|
|
|
4
|
|
589
|
use aliased 'OpenTracing::Implementation::DataDog::ScopeManager'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
25
|
|
46
|
4
|
|
|
4
|
|
569
|
use aliased 'OpenTracing::Implementation::DataDog::SpanContext'; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
28
|
|
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
4
|
|
2751
|
use Ref::Util qw/is_plain_hashref/; |
|
4
|
|
|
|
|
2367
|
|
|
4
|
|
|
|
|
335
|
|
49
|
4
|
|
|
4
|
|
38
|
use Types::Standard qw/Object/; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
46
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This is a L<OpenTracing SpanContext|OpenTracing::Interface::SpanContext> |
56
|
|
|
|
|
|
|
compliant implementation with DataDog specific extentions |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 EXTENDED ATTRIBUTES |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 C<scope_manager> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
A L<OpenTracing::Types::ScopeManger> that now defaults to a |
71
|
|
|
|
|
|
|
L<DataDog::ScopeManger|OpenTracing::Implementation::DataDog::ScopeManager> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has '+scope_manager' => ( |
76
|
|
|
|
|
|
|
default => sub { ScopeManager->new }, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DATADOG SPECIFIC ATTRIBUTES |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 C<agent> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
An agent that has a C<send_span> method that will get called on a `on_finish`. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
See L<DataDog::Agent|OpenTracing::Implementation::DataDog::Agent> for more. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
It also accepts a plain hash refference with key-value pairs suitable to |
94
|
|
|
|
|
|
|
construct a Agent. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
has agent => ( |
99
|
|
|
|
|
|
|
is => 'lazy', |
100
|
|
|
|
|
|
|
isa => Object, |
101
|
|
|
|
|
|
|
handles => [qw/send_span/], |
102
|
|
|
|
|
|
|
coerce |
103
|
|
|
|
|
|
|
=> sub { is_plain_hashref $_[0] ? Agent->new( %{$_[0]} ) : $_[0] }, |
104
|
|
|
|
|
|
|
default => sub { {} }, # XXX this does not return an Object !!! |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub extract_context { |
110
|
|
|
|
|
|
|
undef |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub inject_context { ... } |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub build_span { |
120
|
|
|
|
|
|
|
my $self = shift; |
121
|
|
|
|
|
|
|
my %opts = @_; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $span = Span->new( |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
operation_name => $opts{ operation_name }, |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
child_of => $opts{ child_of }, |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
maybe |
130
|
|
|
|
|
|
|
start_time => $opts{ start_time }, |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
maybe |
133
|
|
|
|
|
|
|
tags => $opts{ tags }, |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
context => $opts{ context }, |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
on_finish => sub { |
138
|
|
|
|
|
|
|
my $span = shift; |
139
|
|
|
|
|
|
|
$self->send_span( $span ) |
140
|
|
|
|
|
|
|
}, |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return $span |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub build_context { |
150
|
|
|
|
|
|
|
my $self = shift; |
151
|
|
|
|
|
|
|
my %opts = @_; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $span_context = SpanContext->new( |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
resource_name => $opts{ resource_name }, |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
maybe |
158
|
|
|
|
|
|
|
service_name => $opts{ service_name }, |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
maybe |
161
|
|
|
|
|
|
|
service_type => $opts{ service_type }, |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
return $span_context |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SEE ALSO |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=over |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item L<OpenTracing::Implementation::DataDog> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Sending traces to DataDog using Agent. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item L<OpenTracing::Role::Tracer> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Role for OpenTracing Implementations. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHOR |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Theo van Hoesel <tvanhoesel@perceptyx.com> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
'OpenTracing::Implementation::DataDog' |
192
|
|
|
|
|
|
|
is Copyright (C) 2019 .. 2020, Perceptyx Inc |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
195
|
|
|
|
|
|
|
the terms of the Artistic License 2.0. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This package is distributed in the hope that it will be useful, but it is |
198
|
|
|
|
|
|
|
provided "as is" and without any express or implied warranties. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
For details, see the full text of the license in the file LICENSE. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |