File Coverage

blib/lib/OpenTelemetry/Exporter/OTLP/Logs.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition 9 24 37.5
subroutine 4 4 100.0
pod 0 1 0.0
total 33 49 67.3


line stmt bran cond sub pod time code
1 1     1   151915 use Object::Pad ':experimental(init_expr)';
  1         9575  
  1         4  
2             # ABSTRACT: An OpenTelemetry Protocol log exporter
3              
4             package OpenTelemetry::Exporter::OTLP::Logs;
5              
6             our $VERSION = '0.021';
7              
8 1     1   699 class OpenTelemetry::Exporter::OTLP::Logs :isa(OpenTelemetry::Exporter::OTLP) {
  1         6  
  1         234  
9 1     1   125 use OpenTelemetry::Common 'config';
  1         2  
  1         675  
10              
11             my $COMPRESSION = eval { require Compress::Zlib; 'gzip' } // 'none';
12              
13 1     1 0 295144 sub BUILDARGS ( $class, %args ) {
  1         2  
  1         2  
  1         2  
14             $args{endpoint}
15             //= config('EXPORTER_OTLP_LOGS_ENDPOINT')
16 1   33     23 // do {
      33        
17 1   50     36 my $base = config('EXPORTER_OTLP_ENDPOINT')
18             // 'http://localhost:4318';
19              
20 1         22 ( $base =~ s|/+$||r ) . '/v1/logs';
21             };
22              
23             # We cannot rely on the defaults on the base OTLP exporter
24             # because at least for now, that one defaults to the TRACES
25             # variables. Once it doesn't, we can simplify this to match
26             # the code in the Traces exporter
27             $args{compression}
28 1   33     139 //= config()
      33        
29             // $COMPRESSION;
30              
31 1   50     104 $args{timeout} //= config() // 10;
      33        
32 1   50     84 $args{headers} //= config() // {};
      33        
33              
34 1         52 %args;
35             }
36             }