BufferedEntry
A dict entry in the Monitor buffer, representing a trace or span waiting to be flushed.
Overview
The Monitor maintains an internal buffer list of entries. Each entry is a dict that tracks whether the item is ready to flush, what category it is, and the underlying trace or span data. You can inspect the buffer to observe pending items or build custom flush logic.
Type Definition
Each entry in monitor.buffer is a dict with the following shape:
{
"ready": bool,
"category": "trace" | "span",
"data": Trace | Span,
}
Fields
Whether this entry is ready to be flushed to the API. An entry becomes ready when all required fields have been set. The background flush loop only sends entries where ready is True.
The type of buffered item. Either "trace" for a Trace or "span" for a Span.
The actual Trace or Span instance. Access the underlying API payload via data.trace or data.span respectively.
Usage
Inspecting the buffer
from adaline.main import Adaline
adaline = Adaline()
monitor = await adaline.init_monitor(project_id="project_abc123")
trace = monitor.log_trace(name="My Trace")
span = trace.log_span(name="My Span")
for entry in monitor.buffer:
print(f"category={entry['category']}, ready={entry['ready']}")
if entry["category"] == "trace":
print(f" trace name: {entry['data'].trace.trace.name}")
elif entry["category"] == "span":
print(f" span name: {entry['data'].span.span.name}")
Counting entries by category
trace_count = sum(1 for e in monitor.buffer if e["category"] == "trace")
span_count = sum(1 for e in monitor.buffer if e["category"] == "span")
ready_count = sum(1 for e in monitor.buffer if e["ready"])
print(f"Buffer: {len(monitor.buffer)} items ({trace_count} traces, {span_count} spans, {ready_count} ready)")
Checking buffer before flush
if any(e["ready"] for e in monitor.buffer):
await monitor.flush()
print(f"Sent: {monitor.sent_count}, Dropped: {monitor.dropped_count}")
- Monitor — owns the buffer and manages flushing
- Trace — the
data value when category is "trace"
- Span — the
data value when category is "span"