Observability
Category: Observability
Source: observability.dart
Classes
ObservabilityEvent
Constructor
dart
ObservabilityEvent(
this.name, {
DateTime? timestamp,
Map<String, dynamic>? attributes,
})Properties
| Property | Type | Description |
|---|---|---|
name | String | |
timestamp | DateTime | |
attributes | Map<String, dynamic> |
ObservabilitySpan
A span representing a unit of work in the observability trace.
Constructor
dart
ObservabilitySpan({
required this.name,
required this.kind,
String? traceId,
this.parentSpanId,
Map<String, dynamic>? attributes,
})Properties
| Property | Type | Description |
|---|---|---|
name | String | |
kind | String | |
traceId | String | |
spanId | String | |
parentSpanId | String? | |
attributes | Map<String, dynamic> | |
events | List<ObservabilityEvent> | |
statusCode | String | |
statusMessage | String? | |
start | DateTime get | |
endTime | DateTime? get | |
duration | Duration get | |
start | DateTime get | |
endTime | DateTime? get | |
duration | Duration get |
Methods
void addEvent(String name, {Map<String, dynamic>? attributes})
void setStatus(String code, {String? message})
void end({Map<String, dynamic>? extra})
abstract ObservabilitySink
A sink that receives completed spans for export to an observability backend.
Methods
void onSpan(ObservabilitySpan span)
Receives a completed [span] for processing.
Future<void> flush()
Flushes any buffered spans to the backend.
Future<void> close()
Closes this sink, releasing any held resources.
Observability
Central coordinator for tracing spans and routing them to registered sinks.
Constructor
dart
Observability({required this._debugController})Properties
| Property | Type | Description |
|---|---|---|
activeSpan | ObservabilitySpan? | |
debugEnabled | bool get | |
sinkCount | int get | |
autoFlushEnabled | bool get | |
debugEnabled | bool get | |
sinkCount | int get | |
autoFlushEnabled | bool get |
Methods
void addSink(ObservabilitySink sink)
Registers a [sink] to receive completed spans.
`ObservabilitySpan startSpan(
String name, {
String kind = 'internal',
Map<String, dynamic>? attributes,
ObservabilitySpan? parent,
})`
Starts a new span with the given [name].
void endSpan(ObservabilitySpan span, {Map<String, dynamic>? extra})
Ends a [span] and forwards it to all registered sinks.
void startAutoFlush(Duration interval)
Future<void> flush()
Flushes all registered sinks.
Future<void> close()
Closes all registered sinks.