> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# BufferedEntry

# BufferedEntry

A dict entry in the [Monitor](/docs/reference/sdk/v2/python/classes/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:

```python theme={null}
{
    "ready": bool,
    "category": "trace" | "span",
    "data": Trace | Span,
}
```

### Fields

<ParamField body="ready" type="bool" required>
  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`.
</ParamField>

<ParamField body="category" type="str" required>
  The type of buffered item. Either `"trace"` for a [Trace](/docs/reference/sdk/v2/python/classes/trace) or `"span"` for a [Span](/docs/reference/sdk/v2/python/classes/span).
</ParamField>

<ParamField body="data" type="Trace | Span" required>
  The actual [Trace](/docs/reference/sdk/v2/python/classes/trace) or [Span](/docs/reference/sdk/v2/python/classes/span) instance. Access the underlying API payload via `data.trace` or `data.span` respectively.
</ParamField>

***

## Usage

### Inspecting the buffer

```python theme={null}
from adaline.main import Adaline

adaline = Adaline()
monitor = 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

```python theme={null}
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

```python theme={null}
if any(e["ready"] for e in monitor.buffer):
    await monitor.flush()

print(f"Sent: {monitor.sent_count}, Dropped: {monitor.dropped_count}")
```

***

## Related

* [Monitor](/docs/reference/sdk/v2/python/classes/monitor) — owns the buffer and manages flushing
* [Trace](/docs/reference/sdk/v2/python/classes/trace) — the `data` value when `category` is `"trace"`
* [Span](/docs/reference/sdk/v2/python/classes/span) — the `data` value when `category` is `"span"`
