# Tutorial 4: Score live traces

**Time:** \~30 minutes **Level:** Intermediate **You'll build:** A continuous trace evaluation running on real production traffic.

## What you'll learn

* How to ingest traces from your application
* How to build a trace evaluation
* How to schedule continuous runs
* How to alert on score drift

## Prerequisites

* [ ] Completed [Tutorials 1 and 2](/2.-get-started/all-tutorials.md)
* [ ] An application emitting AI calls (real or simulated)
* [ ] A scoring config (scorers + judges) you want to apply

## Step 1: Ingest traces

In your application, after each AI call:

```python
from layerlens import Stratix
client = Stratix()

client.traces.create(
 id=correlation_id,
 name="answer-question",
 inputs={"prompt": prompt_text},
 outputs={"response": response_text},
 spans=[
 {"name": "retrieval", "kind": "tool", "inputs": {...}, "outputs": {...}},
 {"name": "llm", "kind": "llm", "model": "claude-opus-4-7", "inputs": {...}, "outputs": {...}}
 ],
 tags={"env": "production", "feature": "support-bot"}
)
```

For batch ingestion:

```python
client.traces.upload("./traces.jsonl")
```

## Step 2: Build the trace evaluation

```python
trace_eval = client.trace_evaluations.create(
 trace_set={"tags": {"env": "production", "feature": "support-bot"}},
 scorers=["scorer-id-1"],
 judges=["judge-id-1"],
 schedule="hourly",
)
print(trace_eval.id)
```

## Step 3: Watch a few runs

After an hour, scores start populating. Open **Premium → Agent Evaluation → Trace evaluations** → your trace eval. The score-over-time chart fills in.

## Step 4: Configure thresholds

```python
client.trace_evaluations.set_alert(
 trace_eval_id=trace_eval.id,
 metric="judge.helpfulness.pass_rate",
 threshold=0.85,
 direction="below",
)
```

When pass rate drops below 85%, you get notified.

## Step 5: Watch the trend

Over a week, the score-over-time chart tells you whether quality is steady or drifting. Drift is the early-warning signal you wanted.

## What's next

* [Tutorial 5: GEPA-optimize a judge](/9.-improve-tune-the-system/05-gepa-optimize.md)
* [Concept: Continuous evaluation](/7.-observe-see-whats-happening/continuous-evaluation.md)
* [Workflow: Observe](/8.-evaluate-score-the-outputs/workflow.md)
* [Stratix Premium — Trace evaluations](/8.-evaluate-score-the-outputs/trace-evaluations.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.layerlens.ai/8.-evaluate-score-the-outputs/04-score-traces.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
