NAME

OpenTelemetry::Exporter - Abstract interface of an OpenTelemetry exporter

SYNOPSIS

use Object::Pad;
use Future::AsyncAwait;

class My::Exporter :does(OpenTelemetry::Exporter) {
    method export      ( $spans, $timeout // undef ) { ... }
    method shutdown    (         $timeout // undef ) { ... }
    method force_flush (         $timeout // undef ) { ... }
}

# Use it with a span processor
my $processor = OpenTelemetry::SDK::Trace::Span::Processor::Batch->new(
    exporter => My::Exporter->new,
);

# Register it with the OpenTelemetry tracer provider
OpenTelemetry->tracer_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 generated by traces, and send it to whoever needs to process that data.

Exporters receive the data they export from a span processor, which must implement the interface defined in OpenTelemetry::Trace::Span::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( \@spans, $timeout // undef );

Takes an array reference with readable spans (such as those provided by OpenTelemetry::SDK::Trace::Span::Readable) 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 = $exporter->shutdown( $timeout // undef );

Takes an optional timeout value and returns the outcome of the shutdown process. 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 return value 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 the outcome of the flushing process. Flushing signals to the exporter that it should export the data for any unexported spans as soon as possible. This could be due to an imminent shutdown, but does not have to be.

The return value will be one of the "Trace export results" in OpenTelemetry::Constants.

SEE ALSO

OpenTelemetry::Constants
OpenTelemetry::Trace::Span::Processor
OpenTelemetry::SDK
OpenTelemetry::SDK::Trace::Span::Readable

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.