File Coverage

blib/lib/Log/Log4perl/OpenTracing.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 27 29 93.1


line stmt bran cond sub pod time code
1             package Log::Log4perl::OpenTracing;
2              
3 3     3   432238 use strict;
  3         24  
  3         95  
4 3     3   17 use warnings;
  3         5  
  3         132  
5              
6             our $VERSION = 'v0.1.0';
7              
8 3     3   1178 use Log::Log4perl::Layout::PatternLayout;
  3         33949  
  3         93  
9 3     3   1409 use OpenTracing::GlobalTracer;
  3         35028  
  3         22  
10              
11 3     3   1792 use Hash::Fold qw/flatten/;
  3         490432  
  3         25  
12              
13             do {
14             local $Log::Log4perl::ALLOW_CODE_IN_CONFIG_FILE =
15             $Log::Log4perl::ALLOW_CODE_IN_CONFIG_FILE +1;
16            
17             Log::Log4perl::Layout::PatternLayout::add_global_cspec(
18             O => \&get_opentracing_context_with_curlies
19             );
20             };
21              
22             sub get_opentracing_context_with_curlies {
23 1     1 0 7842 my ($layout, $message, $category, $priority, $caller_level) = @_;
24            
25 1         4 my $curlies = $layout->{curlies};
26 1         6 my $context = get_opentracing_context();
27            
28 1         16 return flatten( $context )->{$curlies}
29             }
30              
31             sub get_opentracing_context {
32 2     2 0 4231 OpenTracing::GlobalTracer->get_global_tracer->inject_context( {} );
33             }
34              
35             1;