OpenTracing/Integration/HTTP/Tiny.pm

filter: Statementstmt 59.1% 29 / 49 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 1 totaltotal 51.3% 37 / 72 CC 5 SCAR 19.2
CC
5
Cov
50%
load
20.0
__ANON__
6.0
__ANON__
2.0
CRAP 6.8
« OpenTracing/Integration.pm ↑ Summary OpenTracing/Tracer.pm »
1 package OpenTracing::Integration::HTTP::Tiny;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.006'; # VERSION
7 1 our $AUTHORITY = 'cpan:TEAM'; # AUTHORITY
8  
9 1 ▶no indirect;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =encoding utf8
13  
14 =head1 NAME
15  
16 OpenTracing::Integration::HTTP::Tiny - support L<HTTP::Tiny> tracing
17  
18 =head1 SYNOPSIS
19  
20 use OpenTracing::Integration qw(HTTP::Tiny);
21 HTTP::Tiny->new->get('https://metacpan.org');
22  
23 =head1 DESCRIPTION
24  
25 See L<OpenTracing::Integration> for more details.
26  
27 Since this is a core module, it's included in the L<OpenTracing> core distribution as well.
28  
29 =cut
30  
31 1 ▶use Syntax::Keyword::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use Class::Method::Modifiers qw(install_modifier);
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 1 ▶use OpenTracing::DSL qw(:v1);
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 with qw(OpenTracing::Integration);
38  
39 1 my $loaded;
40  
41 0 ▶sub load {
Subroutine load: not called CC=4 SCAR=30.0
Pod undocumented
42 0 my ($class, $load_deps) = @_;
43 0 ▶ return unless $load_deps or HTTP::Tiny->can('new');
Branch: 1 branch
BranchTrueFalseTotal
unless $load_deps or "HTTP::Tiny"->can("new") 0 0 0
Condition0%0/3
$load_deps or "HTTP::Tiny"->can("new")
l!l&&r!l&&!r
000
MC/DC0%0/2
$load_deps or "HTTP::Tiny"->can("new")
$load_deps "HTTP::Tiny"->can("new")
Truth table0%0/3
A or B
A= $load_depsB= "HTTP::Tiny"->can("new")
ABresult
1X1
011
000
44  
45 0 ▶ unless($loaded++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($loaded++) 0 0 0
46 0 require HTTP::Tiny;
47 0 require URI;
48 0 ▶ install_modifier q{HTTP::Tiny}, around => request => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
49 0 my ($code, $self, $method, $url, $args) = @_;
50 0 my $uri = URI->new("$url");
51 0 my $path = $uri->path;
52 0 ▶ $path = '/' unless length $path;
Branch: 1 branch
BranchTrueFalseTotal
unless length $path 0 0 0
53 0 ▶ return trace {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 my ($span) = @_;
55 try {
56 0 $span->tag(
57 'component' => 'HTTP::Tiny',
58 'http.method' => $method,
59 'http.url' => "$url",
60 'span.kind' => 'client',
61 );
62 0 my $res = $self->$code($method, $url, $args);
63 $span->tag(
64 'http.status_code' => $res->{status}
65 0 );
66 0 return $res;
67 0 } catch {
68 0 my $err = $@;
69 0 $span->tag(
70 error => 1,
71 );
72 0 die $@;
73 }
74 0 } operation_name => $path;
75 0 };
76 }
77 }
78  
79 1 1;
80  
81 __END__
« OpenTracing/Integration.pm ↑ Summary OpenTracing/Tracer.pm »