Skip to main content
This guide shows you how to log metrics (evaluation scores, guardrail results) computed in your application code.
When to use client-side metrics: Guardrails (format validation, safety checks, PII detection) are ideal to compute client-side at execution time rather than server-side post-ingestion.

Quick Start

Use enrich_session() to add metrics to the entire trace, or enrich_span() to add metrics to a specific operation.

On the Session

Add metrics that apply to the entire trace:

On a Span

Add metrics to a specific function or operation:

Concepts

Client-Side vs Server-Side Evaluations

Client-side metrics are not overwritten by server-side evaluators with the same name.

Metrics Schema

The metrics object accepts any structure:

Data Types

Nested Data

Access nested fields when charting: metrics.step_evals.0.passed
Nesting limits: Max 5 levels of nested objects, max 2 levels of nested arrays.

Learn More

Chart metrics

Visualize metrics in dashboards

Server-side evaluators

Run evaluations post-ingestion

LLM evaluators

Use LLMs to evaluate outputs

Human annotations

Set up expert review queues

SDK Reference