Judgment Labs Logo
Sdk referenceTypescript

OfflineTracer

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.

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.

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

supportsLiveInstrumentation

:

boolean

Default:

false


Static Method

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.

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

Parameters

config

required

:

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).

function getSpanExporter(): JudgmentSpanExporter

Returns

JudgmentSpanExporter


getSpanProcessor()

Return the offline span processor for this tracer.

function getSpanProcessor(): OfflineJudgmentSpanProcessor

Returns

OfflineJudgmentSpanProcessor


Static Method

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.

const tracer = await Tracer.init({
  projectName: "my-project",
  environment: "production",
});
async function init(config: TracerConfig = {}): Promise<Tracer>

Parameters

config

:

TracerConfig

Tracer configuration options.

Default:

{}

Returns

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

Last updated on