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

# Sampling

> Sampling strategies for high-volume workloads

Reduce overhead by sampling a subset of traces.

***

## Head-Based Sampling

Sample at trace start:

```typescript theme={null}
const lumina = initLumina({
  endpoint: 'http://localhost:9411/v1/traces',
  service_name: 'high-volume-service',
  samplingRate: 0.1, // Sample 10%
});
```

***

## Conditional Sampling

Always sample important traces:

```typescript theme={null}
const lumina = initLumina({
  endpoint: 'http://localhost:9411/v1/traces',
  service_name: 'service',
  samplingRate: 0.1,
  alwaysSampleConditions: {
    error: true,              // Always sample errors
    costUsd: { $gt: 0.5 },   // Always sample expensive calls
  },
});
```

***

## When to Use Sampling

* **> 100K traces/day** — Consider 10-20% sampling
* **> 1M traces/day** — Use 1-5% sampling
* **Production** — Balance cost vs visibility

***

## Impact

**10% sampling:**

* 90% reduction in storage costs
* 90% reduction in ingestion load
* May miss rare errors

**Conditional sampling:**

* Sample routine operations at low rate
* Capture all errors at 100%
* Best of both worlds
