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::Trace::Link - A link to an OpenTelemetry span

SYNOPSIS

    use OpenTelemetry::Trace::Link;

    my $link = OpenTelemetry::Trace::Link->new(
        context    => $span_context,
        attributes => \%attributes,
    );

    # Or more realistically
    use OpenTelemetry;

    my $span = OpenTelemetry->tracer_provider->tracer->create_span(
        ...,
        links => [
            {
                context    => $other_span->context,
                attributes => \%attributes,
            },
            ...
        ],
    );

DESCRIPTION

Spans created by a OpenTelemetry::Trace::Tracer (or one of its subclasses) may be linked to zero or more other spans that are causally related. This can be useful to represent batched operations, where a span representing the entire operation is linked to multiple spans representing each item making up the batch; or fork/join operations, where all forks are under a single span representing the aggregation of all tasks. See the OpenTelemetry specification for more details on links.

Note that links can only be added to a span at creation time, and only through the links parameter to "create_span" in OpenTelemetry::Trace::Tracer. Please refer to that module's documentation for more details.

METHODS

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

new

    my $link = OpenTelemetry::Trace::Link->new(
        context => $span_context,
    );

Create a new link to a different span. The context parameter must be set to a valid OpenTelemetry::Trace::SpanContext, which will identify the span to link to.

context

    $span_context = $link->context;

Retrieves the span context of the span this instance links to.

SEE ALSO

OpenTelemetry::Attributes
OpenTelemetry::SDK::Trace::Span

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.