NAME
OpenTelemetry::Logs::LogRecord::Processor - Abstract interface of an OpenTelemetry log record processor
SYNOPSIS
use Object::Pad;
use Future::AsyncAwait;
class My::Processor :does(OpenTelemetry::Logs::LogRecord::Processor) {
method on_emit ( $log_record ) { ... }
}
# Create it
my $processor = My::Processor->new( ... );
# Register it with the OpenTelemetry tracer provider
OpenTelemetry->logger_provider->add_log_record_processor($processor);
DESCRIPTION
This module provides an abstract role that can be used by classes implementing OpenTelemetry log record processors. Log record processors are objects that are registered with a OpenTelemetry::Logs::LoggerProvider (or, more accurately, with one of its subclasses such as those provided by an OpenTelemetry SDK) to perform additional operations on log records when they are emitted.
The processor is considered to be the start of a pipeline, which must be allowed to end with a OpenTelemetry::Exporter to export the log records to some collector. To this end, processors are expected to accept an optional exporter
parameter to their constructor. But processors can be used for other ends.
METHODS
new
$processor = Class::Implementing::This::Role->new(
exporter => ..., # optional
...
);
Should take an optional exporter set to an instance of a class implementing the OpenTelemetry::Exporter role. Processor classes are free to accept any other parameters they choose.
on_emit
$processor->on_emit( $log_record );
Called when the log record is emitted. It takes the emitted log record as its only parameter.
This method is called synchronously when the log record is emitted, so it should not block or die.
The return value of this method is ignored.
shutdown
$result = await $processor->shutdown( $timeout // undef );
Takes an optional timeout value and returns a Future that will be done when this log record processor has completed shutting down. The shutdown process must include the effects of force_flush, described below. After shutting down, the processor is not expected to do any further work, and should ignore any subsequent calls.
The value of the future will be one of the "Trace Export Results" in OpenTelemetry::Constants.
force_flush
$result = await $processor->force_flush( $timeout // undef );
Takes an optional timeout value and returns a Future that will be done when this log record processor has finished flushing. Flushing signals to the processor that it should process the data for any unprocessed elements as soon as possible. This could be due to an imminent shutdown, but does not have to be.
The value of the future will be one of the "Trace Export Results" in OpenTelemetry::Constants.
SEE ALSO
- Future
- OpenTelemetry::Constants
- OpenTelemetry::Exporter
- OpenTelemetry::Logs::LoggerProvider
- OpenTelemetry::SDK
- OpenTelemetry::SDK::Logs::LogRecord
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by José Joaquín Atria.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.