ContextScope enum

Controls how long the span remains active in context for automatic parent assignment.

When using FaroTracer.startSpan, this determines whether the span should be deactivated from the zone context when the callback completes.

Inheritance
Available extensions

Values

callback → const ContextScope

Span is removed from context when the callback completes.

Async operations scheduled within the callback (e.g., timers, streams) that execute after the callback completes will NOT see this span as their parent. This is the default behavior and is correct for most use cases.

Example:

await Faro().startSpan('parent', (span) async {
  Timer.periodic(Duration(seconds: 1), (timer) {
    // This timer callback runs AFTER the parent callback completes,
    // so spans created here won't have 'parent' as their parent.
    Faro().startSpan('timer-work', (s) async { ... });
  });
});
zone → const ContextScope

Span remains active in context for all async operations in the zone.

Use this when you intentionally want async operations scheduled within the callback (like timers or streams) to inherit this span as their parent, even after the callback completes.

Example:

await Faro().startSpan('background-monitor',
  contextScope: ContextScope.zone,
  (span) async {
    Timer.periodic(Duration(minutes: 1), (timer) {
      // These timer spans WILL have 'background-monitor' as parent
      Faro().startSpan('health-check', (s) async { ... });
    });
  },
);

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<ContextScope>
A constant List of the values in this enum, in order of their declaration.