File Coverage

blib/lib/OpenTelemetry/Proto.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package OpenTelemetry::Proto;
2             # ABSTRACT: The protobuf definitions for the OpenTelemetry Protocol
3              
4             our $VERSION = '0.021';
5              
6 1     1   950 use experimental 'signatures';
  1         2  
  1         9  
7              
8 1     1   732 use File::Share 'dist_dir';
  1         34611  
  1         116  
9 1     1   1227 use Path::Tiny 'path';
  1         27870  
  1         124  
10 1     1   212 use Google::ProtocolBuffers::Dynamic;
  0            
  0            
11             use Feature::Compat::Try;
12              
13             my $g = Google::ProtocolBuffers::Dynamic->new('proto');
14              
15             my $share = do {
16             try { dist_dir 'OpenTelemetry-Exporter-OTLP' }
17             catch($e) { 'share' }
18             };
19              
20             # Generated with
21             #
22             # find . -name "*.proto" | while read proto; do
23             # protoc --experimental_allow_proto3_optional -Iproto -o "$( echo ${proto%%.proto}.pb | sed -re 's/^\.\/proto/share/' )" $proto;
24             # done
25             #
26             # The order of the list below is important! They are compiled
27             # in order because later ones depend on earlier ones.
28             for my $proto (qw(
29             opentelemetry/proto/common/v1/common.pb
30             opentelemetry/proto/resource/v1/resource.pb
31             opentelemetry/proto/trace/v1/trace.pb
32             opentelemetry/proto/metrics/v1/metrics.pb
33             opentelemetry/proto/logs/v1/logs.pb
34              
35             opentelemetry/proto/collector/logs/v1/logs_service.pb
36             opentelemetry/proto/collector/metrics/v1/metrics_service.pb
37             opentelemetry/proto/collector/trace/v1/trace_service.pb
38             )) {
39             $g->load_serialized_string( path("$share/$proto")->slurp );
40              
41             my @parts = split '/', $proto;
42             pop @parts;
43              
44             $g->map({
45             package => join('.', @parts ),
46             prefix => join( '::', map ucfirst, @parts ) =~ s/^Opente/OpenTe/r,
47             });
48             }
49              
50             # FIXME: This should probably be in a different distribution
51             #
52             # Generated with
53             #
54             # cd share/google/rpc
55             # wget https://raw.githubusercontent.com/googleapis/googleapis/6a8c7914d1b79bd832b5157a09a9332e8cbd16d4/google/rpc/status.proto
56             # protoc -o status.pb status.proto
57             # rm status.proto
58             #
59             $g->load_serialized_string( path("$share/google/rpc/status.pb")->slurp );
60             $g->map({
61             package => 'google.rpc',
62             prefix => 'OTel::Google::RPC',
63             });
64              
65             1;