| 1 | package OpenTracing::SpanProxy; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 10 | our $VERSION = '1.006'; # VERSION | |||||||||
| 7 | 10 | our $AUTHORITY = 'cpan:TEAM'; # AUTHORITY | |||||||||
| 8 | |||||||||||
| 9 | 10 | ▶ | use parent qw(OpenTracing::Common); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 10 | ▶ | no indirect; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 10 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | =encoding utf8 | ||||||||||
| 15 | |||||||||||
| 16 | =head1 NAME | ||||||||||
| 17 | |||||||||||
| 18 | OpenTracing::SpanProxy - wrapper around an L<OpenTracing::Span> | ||||||||||
| 19 | |||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||
| 21 | |||||||||||
| 22 | This is the wrapper class that user code would normally receive when working | ||||||||||
| 23 | with spans. It allows the creation of nested subspans, and will automatically | ||||||||||
| 24 | mark the span as complete when the proxy object is discarded. | ||||||||||
| 25 | |||||||||||
| 26 | For methods available here, see L<OpenTracing::Span>. | ||||||||||
| 27 | |||||||||||
| 28 | =cut | ||||||||||
| 29 | |||||||||||
| 30 | =head2 span | ||||||||||
| 31 | |||||||||||
| 32 | Returns the L<OpenTracing::Span> instance that this wraps. | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | 2 | ▶ | sub span { shift->{span} } | ||||||||
|
Subroutine
span: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 37 | |||||||||||
| 38 | =head2 log | ||||||||||
| 39 | |||||||||||
| 40 | Writes a log entry to the L<OpenTracing::Span>. | ||||||||||
| 41 | |||||||||||
| 42 | =cut | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub id { shift->span->id } | ||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub trace_id { shift->span->trace_id } | ||||||||
|
Subroutine
trace_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub parent_id { shift->span->parent_id } | ||||||||
|
Subroutine
parent_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub log { shift->span->log(@_) } | ||||||||
|
Subroutine
log: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub logs { shift->span->logs } | ||||||||
|
Subroutine
logs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub tags { shift->span->tags } | ||||||||
|
Subroutine
tags: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub tag { shift->span->tag(@_) } | ||||||||
|
Subroutine
tag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub reference { shift->span->reference(@_) } | ||||||||
|
Subroutine
reference: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub references { shift->span->references } | ||||||||
|
Subroutine
references: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub start_time { shift->span->start_time } | ||||||||
|
Subroutine
start_time: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub finish_time { shift->span->finish_time } | ||||||||
|
Subroutine
finish_time: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub duration { shift->span->duration(@_) } | ||||||||
|
Subroutine
duration: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub finish { shift->span->finish(@_) } | ||||||||
|
Subroutine
finish: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub is_finished { shift->span->is_finished } | ||||||||
|
Subroutine
is_finished: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub operation_name { shift->span->operation_name } | ||||||||
|
Subroutine
operation_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub flags { shift->span->flags } | ||||||||
|
Subroutine
flags: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 75 | |||||||||||
| 76 | =head2 new_span | ||||||||||
| 77 | |||||||||||
| 78 | Creates a new sub-span under this L<OpenTracing::Span> instance. | ||||||||||
| 79 | |||||||||||
| 80 | =cut | ||||||||||
| 81 | |||||||||||
| 82 | 0 | ▶ | sub new_span { | ||||||||
|
Subroutine
new_span: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 83 | 0 | my ($self, $name, %args) = @_; | |||||||||
| 84 | 0 | my $parent = $self->span; | |||||||||
| 85 | 0 | @args{qw(trace_id parent_id)} = ( | |||||||||
| 86 | $parent->trace_id, | ||||||||||
| 87 | $parent->id, | ||||||||||
| 88 | ); | ||||||||||
| 89 | 0 | $parent->tracer->span( | |||||||||
| 90 | operation_name => $name, | ||||||||||
| 91 | %args | ||||||||||
| 92 | ); | ||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | =head2 DESTROY | ||||||||||
| 96 | |||||||||||
| 97 | Called on destruction, will mark completion on the span by calling | ||||||||||
| 98 | L<OpenTracing::Span/finish>. | ||||||||||
| 99 | |||||||||||
| 100 | =cut | ||||||||||
| 101 | |||||||||||
| 102 | 1 | ▶ | sub DESTROY { | ||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=11.4
| |||||||||||
| 103 | 1 | my ($self) = @_; | |||||||||
| 104 | 1 | ▶ | return if ${^GLOBAL_PHASE} eq 'DESTRUCT'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 1 | ▶ | $self->span->finish unless $self->span->is_finished; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 1 | delete $self->{span}; | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | 10 | 1; | |||||||||
| 110 | |||||||||||
| 111 | __END__ | ||||||||||