The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OpenTelemetry::SDK::Trace::Sampler::AlwaysOn - A sampler that will always sample

SYNOPSIS

    my $sampler = OpenTelemetry::SDK::Trace::Sampler::AlwaysOn->new;

    my $result = $sampler->should_sample( ... );

    unless ( $result->sampled ) {
        # this will never be reached :(
    }

DESCRIPTION

This module provides a sampler whose should_sample method will always return a result that is both sampled and recording.

METHODS

This class implements the OpenTelemetry::SDK::Trace::Sampler role. Please consult that module's documentation for details on the behaviours it provides.

new

    $sampler = OpenTelemetry::SDK::Trace::Sampler::AlwaysOn->new;

Returns a new instance of this sampler. Takes no arguments.

description

    $string = $sampler->description;

Returns the AlwaysOnSampler string.

should_sample

    $result = $sampler->should_sample(
        context    => $context,
        trace_id   => $trace_id,
        kind       => $span_kind,
        name       => $span_name,
        attributes => \%attributes,
        links      => \@links,
    );

Returns a OpenTelemetry::SDK::Trace::Sampler::Result that is both sampled and recording. The OpenTelemetry::Propagator::TraceContext::TraceState in the result will be read from the context provided in the context parameter, or from the current context if none is provided.

SEE ALSO

OpenTelemetry::Propagator::TraceContext::TraceState
OpenTelemetry::SDK::Trace::Sampler
OpenTelemetry::SDK::Trace::Sampler::Result

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.