| 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.4'; | |||||||||
| 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 | 15 | ▶ | sub start_guarded_span { | ||||||||
|
Subroutine
start_guarded_span: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | 15 | my $class = shift; | |||||||||
| 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 | 15 | ▶ | Scope::Context->up->reap(sub { $scope->close }); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | return | ||||||||||
| 35 | 15 | } | |||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | # _context_sub_name | ||||||||||
| 40 | # | ||||||||||
| 41 | # Returns the sub_name of our caller (caller of `start_guarded_span`) | ||||||||||
| 42 | 5 | ▶ | sub _context_sub_name { Scope::Context->up->up->sub_name } | ||||||||
|
Subroutine
_context_sub_name: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | 3 | 1; | |||||||||