---
title: OfflineTracer
seo:
  title: OfflineTracer — TypeScript SDK
  description: Tracer for offline / experiment-style runs. (TypeScript SDK)
description: Tracer for offline / experiment-style runs.
---

Behaves like `Tracer` for span creation and `@Tracer.observe`, with
two differences:

* Spans are pushed to the project's *offline* OTLP endpoint and stored
  in the `offline_otel_traces` ClickHouse table. They do **not** appear
  on the live monitoring page.
* Each completed root span produces a new `Example` that is appended
  to the caller-supplied `dataset` list. The example carries the
  `offline_trace_id` of the offline trace plus any static
  `exampleFields` configured at init time.

Unlike `Tracer`, `OfflineTracer` requires all credentials upfront and
throws if any are missing — there is no no-op fallback. Prefer
`judgeval.offlineTracer({ ... })` over calling `OfflineTracer.create`
directly so credentials are reused from the active `Judgeval` client.

```typescript
import { Judgeval, type Example } from "judgeval";

const judgeval = await Judgeval.create({ projectName: "my-project" });
const dataset: Example[] = [];
const tracer = await judgeval.offlineTracer({
  dataset,
  exampleFields: { input: "What is 2+2?", expected_output: "4" },
});
```

## Attributes

| Prop | Type | Default | Description |
| - | - | - | - |
| `supportsLiveInstrumentation?` | `boolean` | `false` | |

***

<Badge>
  Static Method
</Badge>

## create()

Create and activate a new `OfflineTracer`.

> **Throws**
>
> Error if `projectName`, `apiKey`, `organizationId`, or
> `apiUrl` cannot be resolved (explicit arg or env var), or if the
> project cannot be found on the backend.

```typescript
async function create(config: OfflineTracerConfig): Promise<OfflineTracer>
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `config` | `OfflineTracerConfig` | - | |

### Returns

`Promise<OfflineTracer>`

***

## getSpanExporter()

Return the offline span exporter for this tracer.

Targets the project's offline OTLP endpoint. Credentials are
guaranteed present (validated in `create`).

```typescript
function getSpanExporter(): JudgmentSpanExporter
```

### Returns

`JudgmentSpanExporter`

***

## getSpanProcessor()

Return the offline span processor for this tracer.

```typescript
function getSpanProcessor(): OfflineJudgmentSpanProcessor
```

### Returns

`OfflineJudgmentSpanProcessor`

***

<Badge>
  Static Method
</Badge>

## init()

Create and activate a new Tracer.

This is the recommended way to initialize tracing. Credentials are
read from environment variables if not provided explicitly.

```typescript
const tracer = await Tracer.init({
  projectName: "my-project",
  environment: "production",
});
```

```typescript
async function init(config: TracerConfig = {}): Promise<Tracer>
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `config?` | `TracerConfig` | `{}` | Tracer configuration options. |

### Returns

`Promise<Tracer>` - A configured and activated `Tracer` instance.
