| 1 | package OpenTracing::Implementation::DataDog::Scope; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | OpenTracing::Implementation::DataDog::Scope - Formailzing active spans | ||||||||||
| 6 | |||||||||||
| 7 | =head SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | duno | ||||||||||
| 10 | |||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | 3 | our $VERSION = 'v0.30.1'; | |||||||||
| 14 | |||||||||||
| 15 | 3 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 3 | with 'OpenTracing::Role::Scope'; | |||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | use OpenTracing::Implementation::DataDog::Utils qw/epoch_floatingpoint/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 3 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 3 | ▶ | use Types::Interface qw/ObjectDoesInterface/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 3 | ▶ | use Types::Standard qw/CodeRef Num/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 3 | has closed_time => ( | |||||||||
| 28 | is => 'rwp', | ||||||||||
| 29 | isa => Num, | ||||||||||
| 30 | predicate => 'has_closed', | ||||||||||
| 31 | # trigger => 1, | ||||||||||
| 32 | init_arg => undef, | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | sub _trigger_closed_time { | ||||||||||
| 36 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_trigger_closed_time: not called CC=2 SCAR=17.9
| |||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | croak "Can't close an already closed scope" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | if $self->has_closed; | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | has after_close => ( | ||||||||||
| 45 | is => 'ro', | ||||||||||
| 46 | isa => CodeRef, | ||||||||||
| 47 | 0 | ▶ | default => sub { sub { } }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 48 | 3 | ); | |||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | sub close { | ||||||||||
| 53 | my $self = shift; | ||||||||||
| 54 | |||||||||||
| 55 | croak "Can't close an already closed scope" | ||||||||||
| 56 | if $self->has_closed; | ||||||||||
| 57 | |||||||||||
| 58 | $self->_set_closed_time( epoch_floatingpoint() ); | ||||||||||
| 59 | |||||||||||
| 60 | return $self->after_close->( $self ) | ||||||||||
| 61 | |||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | sub DEMOLISH { | ||||||||||
| 67 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
DEMOLISH: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 68 | 0 | my $in_global_destruction = shift; | |||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | return if $self->has_closed; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | |||||||||||
| 72 | 0 | croak "Scope not programmatically closed before being demolished"; | |||||||||
| 73 | # | ||||||||||
| 74 | # below might be appreciated behaviour, but you should close yourself | ||||||||||
| 75 | # | ||||||||||
| 76 | 0 | ▶ | $self->close( ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | unless $in_global_destruction; | ||||||||||
| 78 | |||||||||||
| 79 | return | ||||||||||
| 80 | 0 | } | |||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | 3 | 1; | |||||||||