Span

abstract class Span(val name: String, val level: Level, val context: TracingEvent.Span.Context, val parent: TracingEvent.Span?, var startAt: Instant?, var endAt: Instant?, val tags: MutableTags, val events: MutableList<TracingEvent.Span.Event>, var status: TracingEvent.Span.Status) : TracingEvent

Represents a span in a tracing system, which can either be a Local or Remote span.

A span is a unit of work within a trace and may contain child spans, tags, events, and a status. https://opentelemetry.io/docs/specs/otel/trace/api/#span

Inheritors

Constructors

Link copied to clipboard
constructor(id: String, name: String, level: Level, tracer: Tracer, parent: TracingEvent.Span?, traceId: String)

Constructor for creating a Local Span.

constructor(id: String, traceId: String, name: String, level: Level, tracer: Tracer)

Constructor for creating a Remote span instance with the given parameters.

constructor(name: String, level: Level, context: TracingEvent.Span.Context, parent: TracingEvent.Span?, startAt: Instant?, endAt: Instant?, tags: MutableTags, events: MutableList<TracingEvent.Span.Event>, status: TracingEvent.Span.Status)

Types

Link copied to clipboard
data class Context(val traceId: String, val spanId: String, val isRemote: Boolean, val tracer: Tracer)
Link copied to clipboard
data class Event(val name: String, val timestamp: Instant, val tags: Tags)
Link copied to clipboard
class Local(id: String, val name: String, val level: Level, tracer: Tracer, val parent: TracingEvent.Span? = null, traceId: String = parent?.context?.traceId ?: id) : TracingEvent.Span

Represents a local span in a tracing system. A span is a unit of work within a trace and can contain child spans.

Link copied to clipboard
class Remote(id: String, traceId: String, val name: String = "remote-", val level: Level, tracer: Tracer) : TracingEvent.Span

Represents a remote span in a distributed tracing system.

Link copied to clipboard
data class Status(val code: TracingEvent.Span.Status.Code = Code.UNSET, val error: Throwable? = null, val description: String? = null)

Properties

Link copied to clipboard

The context of the span, providing trace and span identifiers.

Link copied to clipboard
var endAt: Instant?

The end timestamp of the span, set when the span ends.

Link copied to clipboard

A list of events associated with the span.

Link copied to clipboard
open val level: Level

The logging level of the span.

Link copied to clipboard
open val name: String

The name of the span.

Link copied to clipboard

The parent span, if any; can be null.

Link copied to clipboard
var startAt: Instant?

The start timestamp of the span, set when the span starts.

Link copied to clipboard

The status of the span, containing the result of its execution.

Link copied to clipboard

A map of tags associated with the span.

Functions

Link copied to clipboard

Creates and returns a new local span with the given name associated with the current context.

inline fun <T> span(name: String, f: TracingEvent.Span.Local.() -> T): T

Executes a function within the scope of a tracing span.

Link copied to clipboard
open override fun toString(): String