Context class
Represents the immutable context containing active spans, baggage, and other data.
- Annotations
-
- @immutable
Properties
- baggage → Baggage?
-
Gets the baggage from the context.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- span → APISpan?
-
Gets the currently active span in this context, if any
no setter
- spanContext → SpanContext?
-
Gets the current span from the context.
no setter
Methods
-
copyWith<
T> (ContextKey< T> key, T value) → Context - Creates a new Context with the specified value for the given key
-
copyWithBaggage(
Baggage moreBaggage) → Context -
Creates a new Context adding in
moreBaggage
, replacing any existing keys that are the same as the keys inmoreBaggage
Creates a new Context with additional Baggage entries. -
copyWithoutSpan(
) → Context - Creates a new Context without a span or span context
-
copyWithSpanContext(
SpanContext spanContext) → Context - Creates a new Context with the given SpanContext.
-
copyWithValue<
T> (String name, T contextValue) → Context - Creates a new Context with the specified value for the given key Creates a new Context with a new key-value pair added.
-
get<
T> (ContextKey< T> key) → T? - Gets the value added for the ContextKey Returns null if no value is set for this key or if the value's type doesn't match T Gets a value from the context for the specified key.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run<
T> (Future< T> operation()) → Future<T> - Run an operation in a zone with this context
-
runIsolate<
T> (Future< T> computation()) → Future<T> - Runs a computation in a new isolate with this context.
-
serialize(
) → Map< String, dynamic> - Serializes the context into a JSON-compatible map.
-
setCurrentSpan(
APISpan? span) → Context - Sets this context as the current context with the given span active. This is separate from span creation as per the specification.
-
toString(
) → String -
A string representation of this object.
inherited
-
withBaggage(
Baggage baggage) → Context - Creates a new context with the given baggage Send an empty baggage to avoid sending any name/value pairs to an untrusted process.
-
withSpan(
APISpan span) → Context - Creates a new Context with the given span set as active
-
withSpanContext(
SpanContext spanContext) → Context - Creates a new context with the given span context
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Properties
Static Methods
-
clearCurrentSpan(
) → Context - Clears the current span from the context. Returns a new context without the span and span context.
-
currentWithBaggage(
) → Context - Returns the current context with Baggage, creating empty Baggage if needed.
-
deserialize(
Map< String, dynamic> values) → Context - Deserializes a previously serialized context map back into a Context object.
-
resetCurrent(
) → void - Resets the current context to a new empty context.
-
resetRoot(
) → void - Resets the root context to a new empty context.