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::Span::Readable - A readable snapshot of an OpenTelemetry span

SYNOPSIS

use OpenTelemetry;

# Spans record data, but offer only limited options to read it
my $span = OpenTelemetry->tracer_provider->tracer->create_span(
    name       => $name,
    attributes => \%attributes,
    ...
);

# The readable span gives access to a readable snapshot of a span
my $readable = $span->snapshot;

DESCRIPTION

While OpenTelemetry::Trace::Span (and OpenTelemetry::SDK::Trace::Span, provided by the OpenTelemetry::SDK distribution) can be used to record data about a logical part of a trace, with what is mostly a write-only interface, this class provides a read-only interface into the span. It is used to propagate the state of the span to the parts of the system that need to read the data that it has recorded, in particular to classes that implement the OpenTelemetry::Trace::Span::Processor role and need to be able to export the span data to external collectors.

The only supported way to create a readable span is through "snapshot" in OpenTelemetry::SDK::Trace::Span. Please refer to that method's documentation for details.

METHODS

dropped_events

$count = $readable->dropped_events;

Returns the number of events that could not be recorded on this span because they would have exceeded the maximum number of events, as set by "event_count_limit" in OpenTelemetry::SDK::Trace::SpanLimits.

$count = $readable->dropped_links;

Returns the number of links that could not be recorded on this span because they would have exceeded the maximum number of events, as set by "link_count_limit" in OpenTelemetry::SDK::Trace::SpanLimits.

end_timestamp

$timestamp = $readable->end_timestamp;

Returns the end timestamp of this span.

events

@events = $readable->events;

Returns the list of events recorded in this span. Elements will be instances of OpenTelemetry::Trace::Event.

hex_parent_span_id

$string = $readable->hex_parent_span_id;

Returns the ID of the parent of this span as a lowercase hexadecimal string, as returned by "parent_span_id".

hex_span_id

$string = $readable->hex_span_id;

Returns an hexadecimal string representation of the ID of this span as returned by "span_id".

hex_trace_id

$string = $readable->hex_trace_id;

Returns an hexadecimal string representation of the trace ID of this span as returned by "trace_id".

instrumentation_scope

$scope = $readable->instrumentation_scope;

Returns the scope of this span. The scope will be an instance of OpenTelemetry::SDK::InstrumentationScope. The scope will be the one that was associated by the OpenTelemetry::Trace::TracerProvider to the OpenTelemetry::Trace::Tracer that created this span.

kind

$kind = $readable->kind;

Returns the kind of this span. The value will be one of "Span Kinds" in OpenTelemetry::Constants.

@links = $readable->links;

Returns the list of links recorded in this span. Elements will be instances of OpenTelemetry::Trace::Link.

name

$name = $readable->name;

Returns the name that was given to this span either at creation time, when "create_span" in OpenTelemetry::Trace::Tracer was called; or at a later point in time with "set_name" in OpenTelemetry::Trace::Span.

parent_span_id

$id = $readable->parent_span_id;

Returns the binary ID of the parent span of this span. If this span is a root span, without a parent, this will return "INVALID_SPAN_ID" in OpenTelemetry::Constants.

resource

$resource = $readable->resource;

Returns the resource of this span. The resource will be an instance of OpenTelemetry::SDK::Resource. The resource will be the one that was associated by the OpenTelemetry::Trace::TracerProvider to the OpenTelemetry::Trace::Tracer that created this span.

span_id

$id = $readable->span_id;

Returns the binary ID of this span.

start_timestamp

$timestamp = $readable->start_timestamp;

Returns the start timestamp of this span.

status

$status = $readable->status;

Returns the status of this span as an instance of OpenTelemetry::Trace::Span::Status. The value will represent what was set by "set_status" in OpenTelemetry::Trace::Span.

trace_flags

$flags = $readable->trace_flags;

Returns the trace flags of this span as an instance of OpenTelemetry::Propagator::TraceContext::TraceFlags.

trace_id

$id = $readable->trace_id;

Returns the binary trace ID of this span.

trace_state

$state = $readable->trace_state;

Returns the trace state of this span as an instance of OpenTelemetry::Propagator::TraceContext::TraceState.

SEE ALSO

OpenTelemetry::Propagator::TraceContext::TraceState
OpenTelemetry::Propagator::TraceContext::TraceFlags
OpenTelemetry::SDK
OpenTelemetry::SDK::InstrumentationScope
OpenTelemetry::SDK::Resource
OpenTelemetry::SDK::Trace::Span
OpenTelemetry::SDK::Trace::SpanLimits
OpenTelemetry::SDK::Trace::Span::Processor
OpenTelemetry::Trace::Event
OpenTelemetry::Trace::Span
OpenTelemetry::Trace::Span::Status
OpenTelemetry::Trace::Tracer
OpenTelemetry::Trace::TracerProvider

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.