Tracer class
SDK implementation of the APITracer interface.
A Tracer is responsible for creating and managing spans. Each Tracer is associated with a specific instrumentation scope and can create spans that represent operations within that scope.
This implementation delegates some functionality to the API Tracer implementation while adding SDK-specific behaviors like sampling and span processor notification.
Note: Per OTEP 0265, span events are being deprecated and will be replaced by the Logging API in future versions.
More information: https://opentelemetry.io/docs/specs/otel/trace/sdk/
- Implementers
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
- enabled ↔ bool
-
Returns true if the tracer is enabled and will create sampling spans.
This should be checked before performing expensive operations to create spans.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Gets the name of the tracer, usually of a library, package or module
no setter
- provider → TracerProvider
-
Gets the provider that created this tracer.
no setter
- resource → Resource?
-
Gets the resource associated with this tracer's provider.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sampler → Sampler?
-
Gets the sampler associated with this tracer.
If no sampler was specified for this tracer, uses the provider's sampler.
no setter
- schemaUrl → String?
-
Gets the schema URL of the tracer
no setter
- version → String?
-
Gets the version, usually of the instrumented library, package or module
no setter
Methods
-
createSpan(
{required String name, SpanContext? spanContext, APISpan? parentSpan, SpanKind kind = SpanKind.internal, Attributes? attributes, List< SpanLink> ? links, List<SpanEvent> ? spanEvents, DateTime? startTime, bool? isRecording = true, Context? context}) → Span - Creates a span with specific options Creates a span with the specified parameters without making it active in any context.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordSpan<
T> ({required String name, required T fn(), SpanKind kind = SpanKind.internal, Attributes? attributes}) → T - Convenience method that starts a span and runs function fn on error, records the exception and sets status to SpanStatusCode.Error ends the span, always
-
recordSpanAsync<
T> ({required String name, required Future< T> fn(), SpanKind kind = SpanKind.internal, Attributes? attributes}) → Future<T> - Convenience method thatstarts a span and runs function fn and awaits its future on error, records the exception and sets status to SpanStatusCode.Error ends the span, always
-
startActiveSpan<
T> ({required String name, required T fn(APISpan span), SpanKind kind = SpanKind.internal, Attributes? attributes}) → T - TODO - needs better doc. Is recordSpan superfluous?
-
startActiveSpanAsync<
T> ({required String name, required Future< T> fn(APISpan span), SpanKind kind = SpanKind.internal, Attributes? attributes}) → Future<T> - Same as startActiveSpan but awaits the future
-
startSpan(
String name, {Context? context, SpanContext? spanContext, APISpan? parentSpan, SpanKind kind = SpanKind.internal, Attributes? attributes, List< SpanLink> ? links, bool? isRecording = true}) → Span -
Starts a new
APISpan. -
startSpanWithContext(
{required String name, required Context context, SpanKind kind = SpanKind.internal, Attributes? attributes}) → APISpan - Starts a span with the given context instead of the current context Sets the current span in the given context
-
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.
inherited