NAME

OpenTelemetry::Propagator::TraceContext - Propagate context using the W3C TraceContext format

SYNOPSIS

use OpenTelemetry::Trace;
use OpenTelemetry::Propagator::TraceContext;

my $propagator = OpenTelemetry::Propagator::TraceContext;

# Inject TraceContext data from the context to a carrier
my $carrier = {};
$propagator->inject( $carrier, $context );

# Extract TraceContext data from a carrier to the context
my $new_context = $propagator->extract( $carrier, $context );

# The TraceContext data will be in the span in the context
my $span = OpenTelemetry::Trace->span_from_context($new_context);

DESCRIPTION

This package defines a propagator class that can interact with the context (which can be either an implicit or explicit instance of OpenTelemetry::Context) and inject or extract data using the W3C TraceContext format.

It implements the propagator interface defined in OpenTelemetry::Propagator.

METHODS

inject

$propagator = $propagator->inject(
    $carrier,
    $context // OpenTelemetry::Context->current,
    $setter  // OpenTelemetry::Propagator::TextMap::SETTER,
)

extract

$new_context = $propagator->extract(
    $carrier,
    $context // OpenTelemetry::Context->current,
    $getter  // OpenTelemetry::Propagator::TextMap::GETTER,
)

keys

@keys = $propagator->keys

SEE ALSO

OpenTelemetry::Context
OpenTelemetry::Propagator
W3C TraceContext format
OpenTelemetry::TraceContext::W3C

A different distribution written to deal with W3C's tracecontext data, earlier than this distribution or its related OpenTelemetry::SDK

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.