blib/lib/OpenTracing/AutoScope.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 94.8% 37 / 39 CC 4 SCAR 5.9
CC
4
Cov
97%
__ANON__
3.0
start_guarded_span
2.0
BEGIN
1.0
CRAP 1.8
« blib/lib/OpenTracing/WrapScope.pm ↑ Summary
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
BranchTrueFalseTotal
scalar @_ % 2 ? : 10 5 15
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
BranchTrueFalseTotal
unless $scope->can("closed") and $scope->closed 14 1 15
Condition66%2/3
$scope->can("closed") and $scope->closed
!ll&&!rl&&r
0141
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
ABresult
0X0
100
111
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;
« blib/lib/OpenTracing/WrapScope.pm ↑ Summary