NAME

OpenTelemetry::Propagator::TextMap - A context propagator for OpenTelemetry using string key / value pairs

SYNOPSIS

use OpenTelemetry::Propagator::TextMap;

my $propagator = OpenTelemetry::Propagator::TextMap->new;

# Does nothing :(
my $carrier = {};
$propagator->inject( $carrier, $context );

# Does nothing :(
my $new_context = $propagator->extract( $carrier, $context );

DESCRIPTION

This package defines a no-op propagator class that implements the OpenTelemetry::Propagator interface, with the assumption that the carrier can store key / value pairs as strings (in Perl parlance, that the carrier can be used as a hash reference).

It also exposes a setter and a getter that can be used as the default value by any propagator that shares this assumption.

METHODS

new

$propagator = OpenTelemetry::Propagator::TextMap->new

Constructs a new instance of this propagator. This propagator will do nothing.

GETTER

$getter = OpenTelemetry::Propagator::TextMap->GETTER;
$value  = $carrier->$getter($key);

Returns a subroutine reference that takes a carrier data structure and a string key, and returns whatever value the carrier stores under that key. If no value is stored under that key, this getter returns undefined.

This getter assumes the carrier is (or can be used as) a hash reference.

SETTER

$setter = OpenTelemetry::Propagator::TextMap->SETTER;
$carrier->$setter( $key => $value );

Returns a subroutine reference that takes a carrier data structure and a string key / value pair, and stores the value under the key in the carrier. It returns nothing.

This getter assumes the carrier is (or can be used as) a hash reference.

SEE ALSO

OpenTelemetry::Context
OpenTelemetry::Propagator

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.