File Coverage

blib/lib/OpenTracing/Implementation/DataDog/Span.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1             package OpenTracing::Implementation::DataDog::Span;
2              
3             =head1 NAME
4              
5             OpenTracing::Implementation::DataDog::Span - A DataDog Implementation for a Span
6              
7             =cut
8              
9             our $VERSION = 'v0.47.0';
10              
11 15     15   562669 use syntax 'maybe';
  15         85444  
  15         126  
12              
13 15     15   21188 use Moo;
  15         7324  
  15         147  
14 15     15   9834 use MooX::Should;
  15         27298  
  15         150  
15              
16             with 'OpenTracing::Role::Span';
17              
18 15     15   2416 use aliased 'OpenTracing::Implementation::DataDog::SpanContext';
  15         828  
  15         160  
19              
20 15     15   2245 use Types::Standard qw/Str/;
  15         42  
  15         164  
21 15     15   32934 use Ref::Util qw/is_plain_hashref/;
  15         9789  
  15         1173  
22 15     15   129 use Carp;
  15         51  
  15         3245  
23              
24             =head1 DESCRIPTION
25              
26             This is a L<OpenTracing Span|OpenTracing::Interface::Span> compliant
27             implementation whit DataDog specific extentions
28              
29             =cut
30              
31              
32              
33             =head1 EXTENDED ATTRIBUTES
34              
35             =cut
36              
37              
38              
39             =head2 C<operation_name>
40              
41             DataDog requires that its length should not exceed 100 characters.
42              
43             =cut
44              
45             has '+operation_name' => (
46             should => Str->where( 'length($_) <= 100' ),
47             );
48              
49              
50              
51             =head2 C<context>
52              
53             Add coercion from plain hashref
54              
55             =cut
56              
57             has '+context' => (
58             coerce
59             => sub { is_plain_hashref $_[0] ? SpanContext->new( %{$_[0]} ) : $_[0] },
60             default
61             => sub { croak "Can not construct a default SpanContext" },
62             );
63              
64             # OpenTracing does not provide any public method to instantiate a SpanContext.
65             # But rootspans do need to have a context which comes from
66             # the `$TRACER->extract_context` call, or it returns `undef` if there was no
67             # such context.
68             # Passing in a plain hash reference instead of a SpanContext will
69             # instantiate such context with a 'fresh' `trace_id`
70              
71              
72              
73             =head1 SEE ALSO
74              
75             =over
76              
77             =item L<OpenTracing::Implementation::DataDog>
78              
79             Sending traces to DataDog using Agent.
80              
81             =item L<OpenTracing::Role::Span>
82              
83             Role for OpenTracing Implementations.
84              
85             =back
86              
87              
88              
89             =head1 AUTHOR
90              
91             Theo van Hoesel <tvanhoesel@perceptyx.com>
92              
93              
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             'OpenTracing::Implementation::DataDog'
98             is Copyright (C) 2019 .. 2021, Perceptyx Inc
99              
100             This library is free software; you can redistribute it and/or modify it under
101             the terms of the Artistic License 2.0.
102              
103             This package is distributed in the hope that it will be useful, but it is
104             provided "as is" and without any express or implied warranties.
105              
106             For details, see the full text of the license in the file LICENSE.
107              
108              
109             =cut
110              
111             1;