TelemetryBuffer class

In-memory buffer for batching telemetry data before export.

This buffer accumulates telemetry data and flushes it periodically to reduce FFI overhead and improve performance.

Features:

  • Configurable batch size (number of items before auto-flush)
  • Configurable flush interval (time-based auto-flush)
  • Separate buffers for traces, spans, metrics, and events

Constructors

TelemetryBuffer({int batchSize = 100, Duration flushInterval = const Duration(seconds: 30)})
Creates a new telemetry buffer.

Properties

eventCount int
Gets the number of events in the buffer.
no setter
hashCode int
The hash code for this object.
no setterinherited
metricCount int
Gets the number of metrics in the buffer.
no setter
onFlush ↔ void Function()?
Callback to be called when buffer flushes.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
Gets the current buffer size.
no setter
spanCount int
Gets the number of spans in the buffer.
no setter
traceCount int
Gets the number of traces in the buffer.
no setter

Methods

addEvent(TelemetryEvent event) bool
Adds an event to the buffer.
addMetric(Metric metric) bool
Adds a metric to the buffer.
addSpan(Span span) bool
Adds a span to the buffer.
addTrace(Trace trace) bool
Adds a trace to the buffer.
dispose() → void
Disposes the buffer and stops periodic flushing.
flush() TelemetryBatch
Flushes all buffered telemetry data.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stopPeriodicFlush() → void
Stops the periodic flush timer.
toString() String
A string representation of this object.
inherited

Operators

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