---
title: "Batching and why shutdown is last | Grafana Labs"
description: "How the SDK queues and batches generations before it exports them, and the order the samples shut down in."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Batching and why shutdown is last

The SDK sends generation data to the Agent Observability API in **batches** from a **queue** of generations waiting to be exported.

[![Queued generations inside the Agent Observability SDK (queueSize, default 2000), the batch the SDK flushes to the Agent Observability API (batchSize, default 100), and how often the SDK flushes queued generations (flushInterval, default 1s)](https://grafana.com/docs/learning-hub/intro-to-agent-observability/05-capture-your-first-generation/23-batching-and-why-shutdown-is-last/queue-batch-export.svg)](https://grafana.com/docs/learning-hub/intro-to-agent-observability/05-capture-your-first-generation/23-batching-and-why-shutdown-is-last/queue-batch-export.svg "Queued generations inside the Agent Observability SDK (queueSize, default 2000), the batch the SDK flushes to the Agent Observability API (batchSize, default 100), and how often the SDK flushes queued generations (flushInterval, default 1s)")

## The batching defaults

- `batchSize`, default 100: maximum generations per export batch.
- `flushInterval`, default 1s: how often the SDK exports queued generations.
- `queueSize`, default 2000: maximum number of queued generations before the SDK drops new ones.

## Why shutdown is last

`client.shutdown()` in each sample shuts down the client after the capture. If your application also sets up OpenTelemetry tracing and metrics, shut those down after the client.
