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.46.2';
10              
11 15     15   543897 use syntax 'maybe';
  15         82509  
  15         125  
12              
13 15     15   20222 use Moo;
  15         6935  
  15         128  
14 15     15   9938 use MooX::Should;
  15         26254  
  15         181  
15              
16             with 'OpenTracing::Role::Span';
17              
18 15     15   2326 use aliased 'OpenTracing::Implementation::DataDog::SpanContext';
  15         741  
  15         148  
19              
20 15     15   2578 use Types::Standard qw/Str/;
  15         37  
  15         158  
21 15     15   31534 use Ref::Util qw/is_plain_hashref/;
  15         9323  
  15         1090  
22 15     15   122 use Carp;
  15         46  
  15         3260  
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;