| 1 | package OpenTracing::AutoScope; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION = 'v0.107.2'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use OpenTracing::GlobalTracer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Scope::Context; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # start_guarded_span | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # This class-method will take an optional list of key/value pairs (same as | ||||||||||||||||||||||||||||
| 18 | # start_active_span) which should be an even sized list. | ||||||||||||||||||||||||||||
| 19 | # If not, we asume there is a given operation name. | ||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||
| 21 | sub start_guarded_span { | ||||||||||||||||||||||||||||
| 22 | 15 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
start_guarded_span: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 15 | ▶ | my $operation_name = scalar @_ % 2 ? shift : _context_sub_name( ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 15 | my %options = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 15 | my $scope = OpenTracing::GlobalTracer | |||||||||||||||||||||||||||
| 27 | ->get_global_tracer->start_active_span( $operation_name, %options ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # use a closure, so we can carry over $scope until the end of the scope | ||||||||||||||||||||||||||||
| 30 | # where this coderef will be 'reaped' | ||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||
| 32 | Scope::Context->up->reap(sub { | ||||||||||||||||||||||||||||
| 33 | 15 | ▶ | $scope->close unless $scope->can('closed') and $scope->closed | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
$scope->can("closed") and $scope->closed
MC/DC50%1/2
$scope->can("closed") and $scope->closed
$scope->can("closed")
$scope->closed
Truth table66%2/3
A and B
A= $scope->can("closed")B= $scope->closed
| |||||||||||||||||||||||||||||
| 34 | 15 | }); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | return | ||||||||||||||||||||||||||||
| 37 | 15 | } | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # _context_sub_name | ||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||
| 43 | # Returns the sub_name of our caller (caller of `start_guarded_span`) | ||||||||||||||||||||||||||||
| 44 | 5 | ▶ | sub _context_sub_name { Scope::Context->up->up->sub_name } | ||||||||||||||||||||||||||
|
Subroutine
_context_sub_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3 | 1; | |||||||||||||||||||||||||||