| 1 | package OpenTelemetry::Proto; | ||
| 2 | # ABSTRACT: The protobuf definitions for the OpenTelemetry Protocol | ||
| 3 | |||
| 4 | our $VERSION = '0.022'; | ||
| 5 | |||
| 6 | 1 | ▶ | use experimental 'signatures'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | ▶ | use File::Share 'dist_dir'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use Path::Tiny 'path'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 0 | ▶ | use Google::ProtocolBuffers::Dynamic; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 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; | ||