| 1 | package OpenTracing::Implementation::DataDog::Span; | ||||||||||
| 2 | |||||||||||
| 3 | our $VERSION = 'v0.30.1'; | ||||||||||
| 4 | |||||||||||
| 5 | 6 | ▶ | use syntax 'maybe'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 6 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | with 'OpenTracing::Role::Span'; | ||||||||||
| 10 | |||||||||||
| 11 | 6 | use OpenTracing::Implementation::DataDog::Utils qw( | |||||||||
| 12 | random_64bit_int | ||||||||||
| 13 | nano_seconds | ||||||||||
| 14 | 6 | ▶ | ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 6 | ▶ | use Types::Standard qw/CodeRef Object/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | has span_id => ( | ||||||||||
| 21 | is => 'ro', | ||||||||||
| 22 | init_arg => undef, | ||||||||||
| 23 | default => sub{ random_64bit_int() } | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | has child_of => ( | ||||||||||
| 29 | is => 'ro', | ||||||||||
| 30 | isa =>Object, # does Span or does SpanContext | ||||||||||
| 31 | required => 1, | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | has on_DEMOLISH => ( | ||||||||||
| 37 | is => 'ro', | ||||||||||
| 38 | isa => CodeRef, | ||||||||||
| 39 | default => sub { sub { } } | ||||||||||
| 40 | ); | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | sub parent_span_id { | ||||||||||
| 45 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
parent_span_id: not called CC=2 SCAR=17.9
| |||||||||||
| 46 | |||||||||||
| 47 | 0 | my $parent = $self->{ child_of }; | |||||||||
| 48 | 0 | ▶ | return unless $parent->does('OpenTracing::Role::Span'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | return $parent->span_id | |||||||||
| 51 | } | ||||||||||
| 52 | # | ||||||||||
| 53 | # This may not be the right way to implement it, for the `child_of` attribute | ||||||||||
| 54 | # may not be such a good idea, maybe it should use references, but not sure how | ||||||||||
| 55 | # those are used | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub nano_seconds_start_time { nano_seconds( $_[0]->start_time ) } | ||||||||
|
Subroutine
nano_seconds_start_time: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub nano_seconds_duration { nano_seconds( $_[0]->duration ) } | ||||||||
|
Subroutine
nano_seconds_duration: not called CC=1 SCAR=6.9
| |||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | sub DEMOLISH { | ||||||||||
| 68 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
DEMOLISH: not called CC=2 SCAR=17.9
| |||||||||||
| 69 | 0 | my $in_global_destruction = shift; | |||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | $self->on_DEMOLISH->( $self ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | unless $in_global_destruction; | ||||||||||
| 73 | |||||||||||
| 74 | return | ||||||||||
| 75 | 0 | } | |||||||||
| 76 | |||||||||||
| 77 | |||||||||||
| 78 | |||||||||||
| 79 | 1; | ||||||||||