File Coverage

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