NAME
OpenTelemetry::Exporter - Abstract interface of an OpenTelemetry exporter
SYNOPSIS
use Object::Pad;
use OpenTelemetry::SDK::Trace::Span::Processor::Batch;
use Future::AsyncAwait;
class My::Exporter :does(OpenTelemetry::Exporter) {
method export ( $elements, $timeout // undef ) { ... }
async method shutdown ( $timeout // undef ) { ... }
async method force_flush ( $timeout // undef ) { ... }
}
# The exporter interface is the same for exporters regardless of what
# they export.
# Attach it to a processor
my $processor = Some::Processor->new( exporter => My::Exporter->new );
# Register the processor with a provider
$provider->add_span_processor($processor);
DESCRIPTION
This module provides an abstract role that can be used by classes implementing OpenTelemetry exporters. Exporters are objects that can take telemetry data, and send it to some external target.
Exporters receive the data they export from a processor, which must implement the interface defined in OpenTelemetry::Processor.
Although this cannot be enforced in the code, the methods described in this role are all expected to return one of the values from "Trace Export Results" in OpenTelemetry::Constants.
METHODS
export
$result = $exporter->export( \@elements, $timeout // undef );
Takes an array reference with exportable elements (such as readable spans like OpenTelemetry::SDK::Trace::Span::Readable or log records like OpenTelemetry::SDK::Logs::LogRecord) and an optional timeout value, and returns the outcome of exporting the span data.
The return value will be one of the "Trace Export Results" in OpenTelemetry::Constants.
shutdown
$result = await $exporter->shutdown( $timeout // undef );
Takes an optional timeout value and returns a Future that will be done when this exporter has completed shutting down. The shutdown process must include the effects of force_flush, described below. After shutting down, the exporter 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 $exporter->force_flush( $timeout // undef );
Takes an optional timeout value and returns a Future that will be done when this exporter has finished flushing. Flushing signals to the exporter that it should export the data for any unprocessed spans 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::Processor
- OpenTelemetry::SDK::Trace::Span::Readable
- OpenTelemetry::SDK::Logs::LogRecord
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 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.