APITracer class

Tracer is responsible for creating APISpans and propagating context in-process. The API prefix indicates that it's part of the API and not the SDK and generally should not be used since an API without an SDK is a noop. Use the TracerProvider from the SDK instead.

All methods of this class are safe for concurrent use by default: implementations must remain correct when methods are invoked from interleaved asynchronous tasks within an isolate. See Trace API, concurrency requirements.

Properties

attributes ↔ Attributes?
Optional attributes associated with this tracer.
getter/setter pair
currentSpan → APISpan?
Gets the currently active span from the current context
no setter
hashCode → int
The hash code for this object.
no setteroverride
name → String
Gets the name of the tracer, usually of a library, package or module
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schemaUrl → String?
Gets the schema URL of the tracer
final
timeProvider → TimeProvider
Clock used for span start, end, and event timestamps. Inherited from the APITracerProvider that created this tracer; spans created via createSpan are constructed with this clock so all timestamps in a trace are consistent. Defaults to the platform-aware defaultTimeProvider (native: SystemTimeProvider; web: WebTimeProvider).
final
version → String?
Gets the version, usually of the instrumented library, package or module
final

Methods

createSpan({required String name, SpanKind kind = SpanKind.internal, Attributes? attributes, List<SpanLink>? links, List<SpanEvent>? spanEvents, DateTime? startTime, bool? isRecording, Context? context, bool root = false}) → APISpan
Creates a span with specific options without making it active in any context.
isEnabled({SpanKind? kind, Context? context}) → bool
Returns whether this tracer is enabled for the provided arguments. This should be checked before performing expensive operations to create spans.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startSpan(String name, {Context? context, bool root = false, SpanKind kind = SpanKind.internal, Attributes? attributes, List<SpanLink>? links, DateTime? startTime, bool? isRecording = true}) → APISpan
Starts a new APISpan.
toString() → String
A string representation of this object.
inherited
withSpan<T>(APISpan span, T fn()) → T
Executes the provided function with the given span active in the current context. The span remains active only for the duration of the function.
withSpanAsync<T>(APISpan span, Future<T> fn()) → Future<T>
Executes the provided async function with the given span active in the current context. The span remains active throughout the entire async execution.

Operators

operator ==(Object other) → bool
The equality operator.
override