NAME

OpenTelemetry::Propagator::TraceContext::TraceFlags - Represents TraceFlags in a W3C TraceContext

SYNOPSIS

use OpenTelemetry::Propagator::TraceContext::TraceFlags;

$off = OpenTelemetry::Propagator::TraceContext::TraceFlags->new;
say 'Not sampled' unless $off->sampled;

$on = OpenTelemetry::Propagator::TraceContext::TraceFlags->new(1);
say 'Sampled' if $on->sampled;

DESCRIPTION

This class can be used to represent the trace flags as defined in a W3C TraceContext. Currently, this implements version 00 of that standard, so the only flag that is defined is the "sampled" flag.

METHODS

new

$traceflags = OpenTelemetry::Propagator::TraceContext::TraceFlags->new(
    $numeric_value // 0,
);

Takes a positional numeric value to use as the starting value for the flags. The value must be a positive integer less than or equal to 255. If the value is not, a warning will be logged and the value will be discarded.

If no value is given (or if the value given is undefined), the value will be set to a default of 0, meaning all flags are disabled.

flags

$numeric = $traceflags->flags;

Returns the flags as a plan numeric scalar.

sampled

$bool = $traceflags->sampled;

Returns true if the sampled flag is enabled, or false otherwise.

to_string

$string = $traceflags->to_string;

Returns the flags stringified as a lowecase hexadecimal string.

SEE ALSO

OpenTelemetry::Propagator::TraceContext
OpenTelemetry::Trace::SpanContext
W3C TraceContext format

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.