| 1 | 3 | ▶ | use Object::Pad ':experimental(init_expr)'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | # ABSTRACT: A batched OpenTelemetry log record processor | ||||||||||
| 3 | |||||||||||
| 4 | package OpenTelemetry::SDK::Logs::LogRecord::Processor::Batch; | ||||||||||
| 5 | |||||||||||
| 6 | 2 | our $VERSION = '0.101'; | |||||||||
| 7 | |||||||||||
| 8 | class OpenTelemetry::SDK::Logs::LogRecord::Processor::Batch | ||||||||||
| 9 | :isa(OpenTelemetry::Processor::Batch) | ||||||||||
| 10 | :does(OpenTelemetry::Logs::LogRecord::Processor) | ||||||||||
| 11 | 2 | ▶ | { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Feature::Compat::Try; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use OpenTelemetry::Constants -export; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use OpenTelemetry; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 2 | ▶ | use Metrics::Any '$metrics', strict => 1, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | name_prefix => [qw( otel processor batch )]; | |||||||||
| 18 | |||||||||||
| 19 | 2 | $metrics->make_counter( 'failure', | |||||||||
| 20 | description => 'Number of times the log processing pipeline failed irrecoverably', | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 2 | $metrics->make_counter( 'success', | |||||||||
| 24 | description => 'Number of logs that were successfully processed', | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 2 | $metrics->make_counter( 'dropped', | |||||||||
| 28 | name => [qw( logs dropped )], | ||||||||||
| 29 | description => 'Number of logs that could not be processed and were dropped', | ||||||||||
| 30 | labels => [qw( reason )], | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 2 | $metrics->make_counter( 'processed', | |||||||||
| 34 | name => [qw( logs processed )], | ||||||||||
| 35 | description => 'Number of logs that were successfully processed', | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | # FIXME: Experimenting here with different metric names. | ||||||||||
| 39 | # This is probably something we are going to have to do | ||||||||||
| 40 | # sooner or later, because the ones we copied from Ruby | ||||||||||
| 41 | # are incompatible with eg. Prometheus. | ||||||||||
| 42 | # Note that these are _not_ the same metrics that are | ||||||||||
| 43 | # proposed on the specification issue, but these seem to | ||||||||||
| 44 | # make sense for now. | ||||||||||
| 45 | 0 | ▶ | method report_dropped ( $reason, $count ) { | ||||||||
|
Subroutine
report_dropped: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 46 | 0 | $metrics->inc_counter_by( dropped => $count => [ reason => $reason ] ); | |||||||||
| 47 | 0 | $self; | |||||||||
| 48 | 2 | } | |||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | method report_result ( $result, $count ) { | ||||||||
|
Subroutine
report_result: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 51 | 1 | ▶ | if ( $result == EXPORT_RESULT_SUCCESS ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 1 | $metrics->inc_counter('success'); | |||||||||
| 53 | 1 | $metrics->inc_counter_by( processed => $count ); | |||||||||
| 54 | 1 | return $self; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | $metrics->inc_counter('failure'); | |||||||||
| 58 | 0 | $self->report_dropped( 'export-failure' => $count ); | |||||||||
| 59 | 2 | } | |||||||||
| 60 | |||||||||||
| 61 | 2 | ▶ | method on_emit ($log) { | ||||||||
|
Subroutine
on_emit: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 62 | 2 | ▶ | return if $self->done; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 2 | $self->process($log); | |||||||||
| 64 | 2 | return; | |||||||||
| 65 | 2 | } | |||||||||
| 66 | 2 | } | |||||||||