OpenTelemetry/Trace/Tracer.pm

filter: Statementstmt 100% 53 / 53 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 100% 72 / 72 CC 4 SCAR 6.2
CC
4
Cov
100%
in_span
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« OpenTelemetry/Trace/Span/Processor.pm ↑ Summary OpenTelemetry/Context.pm »
1 11 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 # ABSTRACT: A span factory for OpenTelemetry
3  
4 package OpenTelemetry::Trace::Tracer;
5  
6 11 our $VERSION = '0.040';
7  
8 class OpenTelemetry::Trace::Tracer {
9 11 ▶ use Feature::Compat::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶ use Syntax::Keyword::Dynamically;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 ▶ use Ref::Util 'is_coderef';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 11 ▶ use OpenTelemetry::Constants qw( SPAN_STATUS_ERROR SPAN_STATUS_OK );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶ use OpenTelemetry::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 11 ▶ use OpenTelemetry::Trace::Span;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 11 ▶ use OpenTelemetry::Trace;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 11 ▶ use OpenTelemetry::X;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶ method create_span ( %args ) {
Subroutine create_span: called CC=1 SCAR=0.0
Pod documented
20 1 OpenTelemetry::Trace::Span::INVALID;
21 11 }
22  
23 # Experimental
24 5 ▶ method in_span {
Subroutine in_span: called CC=4 SCAR=13.9
Pod documented
25 5 ▶ is_coderef $_[-1] or die OpenTelemetry::X->create(
Branch: 1 branch
BranchTrueFalseTotal
is_coderef($_[-1]) or die "OpenTelemetry::X"->create("Invalid", "Missing required code block in call to Tracer->in_span") 4 1 5
26 Invalid => 'Missing required code block in call to Tracer->in_span',
27 );
28  
29 4 my $block = pop;
30 4 my $name = shift;
31 4 my %args = @_;
32  
33 4 ▶ $args{name} = $name or die OpenTelemetry::X->create(
Branch: 1 branch
BranchTrueFalseTotal
$args{"name"} = $name or die "OpenTelemetry::X"->create("Invalid", "Missing required span name to Tracer->in_span") 3 1 4
34 Invalid => 'Missing required span name to Tracer->in_span',
35 );
36  
37 3 my $span = $self->create_span(%args);
38  
39 3 my $context = OpenTelemetry::Trace->context_with_span($span);
40  
41 3 dynamically OpenTelemetry::Context->current = $context;
42  
43 3 my ( $error );
44 3 try {
45 3 return $block->( $span, $context );
46 }
47 catch ($e) {
48 1 $span->record_exception($e);
49  
50 1 ($error) = split /\n/, "$e", 2;
51 1 $error =~ s/ at \S+ line \d+\.$//;
52  
53 1 die $e;
54 }
55 finally {
56 3 ▶ $span->set_status( SPAN_STATUS_ERROR, $error ) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 1 2 3
57 3 $span->end;
58 }
59 11 }
60 11 }
« OpenTelemetry/Trace/Span/Processor.pm ↑ Summary OpenTelemetry/Context.pm »