File Coverage

blib/lib/OpenTracing/Implementation/DataDog/ScopeManager.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 10 100.0


line stmt bran cond sub pod time code
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             our $VERSION = 'v0.40.0.7-TRIAL';
27              
28 5     5   311013 use Moo;
  5         21  
  5         38  
29              
30 5     5   5850 use OpenTracing::Implementation::DataDog::Scope;
  5         20  
  5         706  
31              
32              
33              
34             =head1 DELEGATED INSTANCE METHODS
35              
36              
37              
38             =head2 build_scope
39              
40             This method will build a new C<Scope> object, that, when C<close> is being
41             called (which you should), the current scope is being set back as the active
42             scope.
43              
44             See L<OpenTracing::Roles::ScopeManager> for the description of the method.
45              
46             =cut
47              
48             sub build_scope {
49             my $self = shift;
50             my $options = { @_ };
51            
52             my $current_scope = $self->get_active_scope;
53            
54             my $scope = OpenTracing::Implementation::DataDog::Scope->new(
55             span => $options->{ span },
56             finish_span_on_close => $options->{ finish_span_on_close },
57             on_close => sub {
58             $self->set_active_scope( $current_scope );
59             }
60             );
61            
62             return $scope
63             }
64              
65              
66              
67             BEGIN {
68 5     5   38 with 'OpenTracing::Role::ScopeManager';
69             }
70              
71              
72              
73             =head1 SEE ALSO
74              
75             =over
76              
77             =item L<OpenTracing::Implementation::DataDog>
78              
79             Sending traces to DataDog using Agent.
80              
81             =item L<OpenTracing::Role::ScopeManager>
82              
83             Role for OpenTracing implementations.
84              
85             =back
86              
87              
88              
89             =head1 AUTHOR
90              
91             Theo van Hoesel <tvanhoesel@perceptyx.com>
92              
93              
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             'OpenTracing::Implementation::DataDog'
98             is Copyright (C) 2019 .. 2020, Perceptyx Inc
99              
100             This library is free software; you can redistribute it and/or modify it under
101             the terms of the Artistic License 2.0.
102              
103             This package is distributed in the hope that it will be useful, but it is
104             provided "as is" and without any express or implied warranties.
105              
106             For details, see the full text of the license in the file LICENSE.
107              
108              
109             =cut
110              
111             1;