Skip to main content

BufferedEntry

The type for items held in the Monitor’s internal buffer before they are flushed to the Adaline API.

Import

import type { BufferedEntry } from '@adaline/client';

Definition

type BufferedEntry =
  | { ready: boolean; category: 'trace'; data: Trace }
  | { ready: boolean; category: 'span'; data: Span };

Fields

FieldTypeDescription
readybooleanWhether the entry is ready to be flushed. An entry becomes ready when end() is called on the trace or span.
category'trace' | 'span'Discriminant that identifies the entry type.
dataTrace | SpanThe trace or span instance held in the buffer.

Usage

Use the monitor’s getBuffer() method to inspect buffered entries. This is useful for debugging flush behavior or verifying that traces and spans are being queued correctly.
import { Adaline } from '@adaline/client';
import type { BufferedEntry } from '@adaline/client';

const adaline = new Adaline();
const monitor = adaline.initMonitor({ projectId: 'my-project' });

const trace = monitor.logTrace({ name: 'Chat Request' });
const span = trace.logSpan({ name: 'LLM Call' });

// Inspect the buffer before ending
const buffer: BufferedEntry[] = monitor.getBuffer();

for (const entry of buffer) {
  if (entry.category === 'trace') {
    console.log(`Trace "${entry.data.name}" — ready: ${entry.ready}`);
  } else {
    console.log(`Span "${entry.data.name}" — ready: ${entry.ready}`);
  }
}

// After ending, entries become ready for flushing
span.end();
trace.end();

See Also

  • Monitor — manages the buffer and flush lifecycle
  • Trace — buffered as category: 'trace'
  • Span — buffered as category: 'span'