| 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 | 15 | our $VERSION = 'v0.47.2'; | |||||||||
| 10 | |||||||||||
| 11 | 15 | ▶ | use syntax 'maybe'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 15 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 15 | ▶ | use MooX::Should; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 15 | with 'OpenTracing::Role::Span'; | |||||||||
| 17 | |||||||||||
| 18 | 15 | ▶ | use aliased 'OpenTracing::Implementation::DataDog::SpanContext'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 15 | ▶ | use Types::Standard qw/Str/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 15 | ▶ | use Ref::Util qw/is_plain_hashref/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 15 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | 15 | 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 | 13 | ▶ | => sub { is_plain_hashref $_[0] ? SpanContext->new( %{$_[0]} ) : $_[0] }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 60 | default | ||||||||||
| 61 | 0 | ▶ | => sub { croak "Can not construct a default SpanContext" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | 15 | ); | |||||||||
| 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 | 15 | 1; | |||||||||