DataDog/ScopeManager.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 20 / 20 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
build_scope
1.0
CRAP 1.0
« DataDog/Scope.pm ↑ Summary DataDog/SpanContext.pm »
1 package OpenTracing::Implementation::DataDog::ScopeManager;
2  
3  
4  
5 =head1 NAME
6  
7 OpenTracing::Implementation::DataDog::ScopeManager - Keep track of active scopes
8  
9 =head1 SYNOPSIS
10  
11 my $span = $TRACER->build_span( ... );
12
13 my $scope_manager = $TRACER->get_scope_manager;
14
15 my $scope = $scope_manager->build_scope(
16 span => $span,
17 finish_span_on_close => true,
18 );
19
20 ...
21
22 $scope->close;
23  
24 =cut
25  
26 10 our $VERSION = 'v0.47.2';
27  
28 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 12 ▶use OpenTracing::Implementation::DataDog::Scope;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 10 has '+active_scope' => (
33 clearer => 'final_scope',
34 );
35  
36 =head1 DELEGATED INSTANCE METHODS
37  
38  
39  
40 =head2 build_scope
41  
42 This method will build a new C<Scope> object, that, when C<close> is being
43 called (which you should), the current scope is being set back as the active
44 scope.
45  
46 See L<OpenTracing::Roles::ScopeManager> for the description of the method.
47  
48 =cut
49  
50 7 ▶sub build_scope {
Subroutine build_scope: called CC=1 SCAR=0.0
Pod documented
51 7 my $self = shift;
52 7 my $options = { @_ };
53
54 7 my $current_scope = $self->get_active_scope;
55
56 my $scope = OpenTracing::Implementation::DataDog::Scope->new(
57 span => $options->{ span },
58 finish_span_on_close => $options->{ finish_span_on_close },
59 on_close => sub {
60 $current_scope ?
61 $self->set_active_scope( $current_scope )
62 :
63 $self->final_scope() #clear
64 }
65 7 );
66
67 7 return $scope
68 }
69  
70  
71  
72 12 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
73 12 with 'OpenTracing::Role::ScopeManager';
74 }
75  
76  
77  
78 =head1 SEE ALSO
79  
80 =over
81  
82 =item L<OpenTracing::Implementation::DataDog>
83  
84 Sending traces to DataDog using Agent.
85  
86 =item L<OpenTracing::Role::ScopeManager>
87  
88 Role for OpenTracing implementations.
89  
90 =back
91  
92  
93  
94 =head1 AUTHOR
95  
96 Theo van Hoesel <tvanhoesel@perceptyx.com>
97  
98  
99  
100 =head1 COPYRIGHT AND LICENSE
101  
102 'OpenTracing::Implementation::DataDog'
103 is Copyright (C) 2019 .. 2021, Perceptyx Inc
104  
105 This library is free software; you can redistribute it and/or modify it under
106 the terms of the Artistic License 2.0.
107  
108 This package is distributed in the hope that it will be useful, but it is
109 provided "as is" and without any express or implied warranties.
110  
111 For details, see the full text of the license in the file LICENSE.
112  
113  
114 =cut
115  
116 10 1;
« DataDog/Scope.pm ↑ Summary DataDog/SpanContext.pm »