From 972b4eeed2604969b5dce8fc92993d865b4f2157 Mon Sep 17 00:00:00 2001 From: ephraimduncan Date: Fri, 30 Oct 2026 08:39:18 +0000 Subject: [PATCH] docs(evals): document datasets, experiments, evaluators, and scores The new Evals section tells how to use datasets, experiments, evaluators, scores, and review queues in the dashboard and from the SDKs. The Evals API reference gives the dataset, experiment, and score routes for code in other languages. Other pages get the parts of Evals that apply to them. The API keys guide gets the Run experiments access, and the alerts guide gets the Eval score drop alert. The environments, privacy, traces, and SDK pages tell about the experiment environment, judges, and scores. --- docs/evals/datasets.mdx | 151 +++++++++++++++++++ docs/evals/evaluators.mdx | 246 ++++++++++++++++++++++++++++++ docs/evals/experiments.mdx | 263 +++++++++++++++++++++++++++++++++ docs/evals/index.mdx | 89 +++++++++++ docs/evals/meta.ts | 8 + docs/evals/review-queues.mdx | 127 ++++++++++++++++ docs/evals/scores.mdx | 132 +++++++++++++++++ docs/index.mdx | 4 +- docs/platform/alerts.mdx | 26 +++- docs/platform/api-keys.mdx | 16 +- docs/platform/environments.mdx | 9 +- docs/platform/privacy.mdx | 19 ++- docs/platform/traces.mdx | 19 ++- docs/reference/evals-api.mdx | 188 +++++++++++++++++++++++ docs/reference/meta.ts | 4 +- docs/sdk/python.mdx | 11 +- docs/sdk/typescript.mdx | 11 +- 17 files changed, 1295 insertions(+), 28 deletions(-) create mode 100644 docs/evals/datasets.mdx create mode 100644 docs/evals/evaluators.mdx create mode 100644 docs/evals/experiments.mdx create mode 100644 docs/evals/index.mdx create mode 100644 docs/evals/meta.ts create mode 100644 docs/evals/review-queues.mdx create mode 100644 docs/evals/scores.mdx create mode 100644 docs/reference/evals-api.mdx diff --git a/docs/evals/datasets.mdx b/docs/evals/datasets.mdx new file mode 100644 index 0000000..d54b177 --- /dev/null +++ b/docs/evals/datasets.mdx @@ -0,0 +1,151 @@ +--- +title: Datasets +description: Make a dataset of test items from traces, sessions, CSV files, or by hand, and keep each change as a version that experiments can use. +lastModified: 2026-10-30 +--- + +A dataset is a list of test items for [experiments](/evals/experiments). Each change to the items makes a new version of the dataset. An experiment keeps the version that it ran on, so you can compare old results after the dataset changes. + +To see the datasets of a project, select **Evals** in the project sidebar, then the **Datasets** tab. The list shows each dataset's **Items**, its newest **Version**, its **Last experiment**, and when it was **Updated**. + +## Make a dataset + + + + On the **Datasets** tab, select **New dataset**. + + + Enter a **Name** of up to 128 characters. Use lowercase letters, digits, dots, dashes, and underscores, such as `support-golden`. The first character must be a letter or a digit. Code finds the dataset by this name. Enter an optional **Description** of up to 500 characters. + + + Under **Start with**, select **Empty**, **A CSV file**, or **Traces that match a filter**. + + + Select **Create dataset**. The dataset opens. If you selected **A CSV file**, the CSV import opens. Read [Import a CSV file](#import-a-csv-file). + + + +Each dataset name is unique in its project. + +With **Traces that match a filter**, enter text in **Trace name has** and select **Last 7 days**, **Last 30 days**, or **Last 90 days**. The match ignores letter case and can be a part of the trace name. The newest 100 traces that match become items, with no expected output. If no trace matches, telemetry.dev makes no dataset. + +## The fields of an item + +| Field | Contents | Limit | +| --- | --- | --- | +| **Input** | A JSON object, such as `{"question": "Where is my refund?"}`. A dashboard experiment uses its keys as the variables of the prompt. | 256 KiB | +| **Expected output** | Optional text: the correct reply. LLM judges and code checks can compare the output with it. | 100,000 characters | +| **Metadata** | A JSON object. The default is `{}`. | 256 KiB | +| **Tags** | Optional labels, separated by commas. telemetry.dev removes spaces at each end and removes repeated tags. | 20 tags, 64 characters each | +| **Split** | Optional. An experiment can run only the items of one split, such as `test` or `dev`. | 64 characters | +| **Source** | Where the item came from: **Trace**, **Session**, **CSV import**, **Review queue**, **Experiment**, or **Added by hand**. You cannot change it. | None | + +A dataset version holds at most 10,000 items. + +## Add or change an item by hand + +On the dataset page, select **Add item**. Fill in the fields, then select **Add item**. To change an item, select its row, change the fields, and select **Save changes**. To remove an item, select **Delete item** in its row menu or in its panel. + +Each save, add, or delete makes a new version. The panel tells you the number of the version that it will make. The older versions, and the experiments on them, keep the item as it was. + +If a different person saved the same item after you opened it, telemetry.dev rejects your save with "Someone changed this item since you opened it". The panel then shows the item from the other person, and your changes are lost. + +## Import a CSV file + +Open the import in one of these ways: + +- Select **Import CSV** on the **Datasets** tab. This makes a new dataset first. +- Select **Import CSV** in the row menu of a dataset. + +Do these steps: + +1. **Upload a file.** Drop the file, or select **Choose a file**. The first row must name the columns. Your browser reads the file. A file can have up to 10,000 rows and 5 MB. +2. **Map columns.** For each column, select an **Item field**: **Input** with a key, **Expected output**, **Tags**, **Split**, **Metadata** with a key, or **Do not import**. The page shows the first 5 rows as items, and the problems that stop the import. +3. Select **Import N items**. The **Check and import** step shows while the import runs. + +The import maps some column names for you. The match ignores letter case: + +| Column name | Item field | +| --- | --- | +| `expected`, `expected output`, `expected_output`, `expected-output`, `answer`, `output`, `reference`, `ideal` | **Expected output** (the first such column) | +| `tag`, `tags`, `label`, `labels`, `category`, `categories` | **Tags** | +| `split` | **Split** | +| `note`, `notes`, `metadata`, `comment`, `comments` | **Metadata** | +| `id` | **Do not import** | +| Other names | **Input**, with the column name as the key | + +The CSV file must use commas between values. Use double quotes around a value that has a comma or a line break, and `""` for a quote in a value. The import ignores blank lines and a byte order mark. + +Each value comes in as a string. The import does not change numbers or JSON text into other types. The import splits a tags value at each comma. A row with an empty expected output comes in without one, and you can add it later. + +The full file becomes one version. An import cannot take the dataset to more than 10,000 items. + +## Add traces and sessions + +You can copy traces and sessions into a dataset from these places: + +- **Traces**, in the **Traces** view: select the check boxes of the rows, then select **Add to dataset**. You can select the rows of one page only. A change of the filters or the page clears the selection. +- A trace: select **Add to dataset** in the header. +- A session: select **Add to dataset** in the header. + +For traces, select the **Dataset** in the dialog. Under **Expected output**, select **Leave it empty** or **Use the trace output**. Then add optional **Tags** and a **Split**, and select **Add item** (**Add N items** for more than one trace). You can add at most 100 traces at a time. + +For a session, select the **Dataset**, then **Add item**. The last reply of the session is always the expected output. + +telemetry.dev makes the item from the trace in this order: + +1. If the SDK recorded the variables of the prompt, they become the input. +2. If not, and the input of the trace is a JSON object, the object becomes the input. +3. If not, the input is `{"input": ""}`. + +The input of a trace is the input of its first span that has one. The output is the reply text of its last span that has an output. An output of more than 100,000 characters is cut, and the item gets the metadata `{"truncated": true}`. + +A session becomes one item. Its input is `{"messages": [...]}` with the user messages of the newest 50 turns. The expected output is the last reply. + +telemetry.dev skips a trace in these conditions, and the toast gives the reason: + +- The environment of the trace has prompt capture off, so telemetry.dev stored no input. Read [Turn off prompt and response capture](/platform/privacy#turn-off-prompt-and-response-capture-for-an-environment). +- Retention deleted the trace. +- The input is larger than an item can hold. + +An item is a copy. It stays in the dataset after retention deletes its trace. + +## Use versions + +Each change to the items makes one version: an add, an edit, a delete, or an import. A change of the name or the description does not make a version. A new dataset is at version 0 until its first change. + +The **Versions** tab lists each version with its **Changes**, the person who made it (**By**), its **Date**, and its **Experiments**. telemetry.dev writes the text of **Changes**, such as "12 items imported from returns.csv". Select a version to see its items. You cannot change the items of an older version. Select **Run experiment** in the row of a version to run an experiment on it. + +The **Version** menu in the header of the dataset page also opens an older version. It lists the newest 100 versions. + +## Find items + +On the **Items** tab, the search matches the text and number values of the input, at each level of the JSON, and the expected output. It does not match keys, metadata, or tags. Use **All tags**, **All splits**, and **All sources** to filter the items. The tab shows 25 items at a time. + +## Rename or delete a dataset + +On the **Datasets** tab, open the row menu of the dataset: + +- Select **Edit name and description** to rename the dataset. Then change the code that loads the dataset by name. +- Select **Delete dataset**, then **Delete dataset** to confirm. + +When you delete a dataset, telemetry.dev also deletes its items, its versions, and the experiments on it. Code that loads the dataset by name then gets an error. You cannot delete a dataset while an experiment on it runs. Stop the experiment first. + +## Read a dataset from code + +`runExperiment` and `run_experiment` read the dataset for you. Read [Run your code](/evals/experiments#run-your-code). To read the items with a different tool, use `GET /v1/datasets/{name}`. Read [Get a dataset](/reference/evals-api#get-a-dataset). + +## Limits + +| Limit | Value | +| --- | --- | +| Name | 128 characters | +| Description | 500 characters | +| Items in a version | 10,000 | +| Traces or items in one add | 100 | +| Session turns in one item | 50 | +| CSV file | 10,000 rows and 5 MB | +| Input or metadata of an item | 256 KiB of JSON each | +| Expected output | 100,000 characters | +| Tags | 20 for each item, 64 characters each | +| Split | 64 characters | diff --git a/docs/evals/evaluators.mdx b/docs/evals/evaluators.mdx new file mode 100644 index 0000000..aeb34ea --- /dev/null +++ b/docs/evals/evaluators.mdx @@ -0,0 +1,246 @@ +--- +title: Evaluators +description: Score replies with LLM judges, code checks, rules, human scores, and user feedback, on experiments and on a sample of live traces. +lastModified: 2026-10-30 +--- + +An evaluator gives a score to a reply. The name of the evaluator is the name of its scores on traces and experiments. The scores of the **User feedback** evaluator have the name `user_feedback`. Evaluators score the items of [experiments](/evals/experiments) and a sample of new traces. + +To see the evaluators of a project, select **Evals** in the project sidebar, then the **Evaluators** tab. The list shows each evaluator's **Type**, **Score**, where it **Runs on**, and its results of the **Last 7 days**. Select an evaluator to open its panel. + +## Types of evaluators + +| Type | What gives the score | Score kinds | +| --- | --- | --- | +| **LLM judge** | A model reads the trace and gives a score with a reason. | Pass / fail, 0 to 1, 1 to 5, labels | +| **Code check** | Your TypeScript or Python function. | Pass / fail, 0 to 1 | +| **Rule** | Conditions on latency, cost, length, text, JSON, or a tool call. | Pass / fail | +| **Human score** | Persons, in review queues and on the trace page. | Pass / fail, a number range, labels | +| **User feedback** | Your app sends the thumbs up or down of your users. | Up / down | + +The **New evaluator** dialog also shows **Pairwise judge**: a model that selects the better of two replies from two experiments. At this time, telemetry.dev saves no scores from pairwise judges. You can run one with **Try it** on two experiments of the same dataset. + +LLM judges, code checks, and rules can score experiments and live traces. Human scores come from [review queues](/evals/review-queues) and from [**Add score**](/evals/scores#add-a-score-on-a-trace) on a trace. User feedback comes from your app. Read [Send scores from your app](/evals/scores#send-scores-from-your-app). + +## Make an evaluator + + + + On the **Evaluators** tab, select **New evaluator**. Select the type, then **Continue**. For **User feedback**, a panel opens with the code that sends feedback. Read [User feedback](#user-feedback). + + + Enter a **Name** of up to 64 characters, and an optional **Description** of up to 500 characters. Names are unique in the project. You cannot use the names `User feedback` and `user_feedback`. + + + Write the judge prompt, the code, or the conditions, and select the kind of score. Read the section of the type below. + + + For an LLM judge, a code check, or a rule, select **Experiments, when you pick it**, **Live traces**, or the two under **Where it runs**. Read [Score live traces](#score-live-traces). For a human score, select **Who gives it**. + + + Select **Create evaluator**. + + + +You cannot change the type of a saved evaluator. + +Before you save an LLM judge, a code check, or a rule, use **Try it** to run it on 5 recent traces or on 5 items of a dataset. **Try it** writes no scores and does not count toward the daily limit. Select a row to read the reason of a score. + +## LLM judges + +An LLM judge sends a prompt to a model and reads a verdict, a number, or a label from the reply. Under **Start from**, select a template: + +| Template | What it checks | Score | +| --- | --- | --- | +| **Correctness** | The reply against the expected output or the order data. | Pass / fail | +| **Hallucination** | Claims that the retrieved documents do not hold. | Pass / fail. The list shows the fail rate. | +| **Helpfulness** | How well the reply solves the problem. | 1 to 5 | +| **Relevance** | That the reply answers the question of the user. | Pass / fail | +| **Toxicity** | Replies that are rude, hateful, or harmful. | Pass / fail. The list shows the fail rate. | +| **Custom** | You write the prompt. | Pass / fail | + +The judge prompt can have up to 20,000 characters. Put these variables in it: + +| Variable | Value | +| --- | --- | +| `{{input}}` | The input of the trace, or of the span when the evaluator scores spans. | +| `{{output}}` | The output of the trace or the span. | +| `{{expected}}` | The expected output of the dataset item. It has a value in experiments only. | +| `{{metadata}}` | The metadata of the dataset item, as JSON. It is `{}` on live traces. The form does not list this variable. | + +For example, the **Correctness** template has this prompt: + +```text +Compare the reply with the expected answer and the order data. +Pass when the reply is correct and does not claim an action that the agent cannot do. + +Question: {{input}} +Reply: {{output}} +Expected: {{expected}} +``` + +Select the **Model** of the judge. You can select only the models of providers that have a key in **Model providers**. The menu shows the models of the other providers with **No key**. Read [Model provider keys](/evals#model-provider-keys). **Ask the judge for its reason** is on by default. The reason shows with the score. + +telemetry.dev cuts each variable at 50,000 characters, and all of the variables together at 200,000 characters. A cut value ends with `…[truncated]`. + +### Judge errors + +If the judge gives no valid score, the score shows **Judge error** with the cause, such as "The judge did not return a verdict." or "OpenAI returned 429. Wait a minute, then run again." telemetry.dev does not send the call again, and it does not score that trace again. Pass rates and averages do not count judge errors. + +## Code checks + +A code check runs your function on each output. Select **TypeScript** or **Python** and write a function named `check`. The code can have up to 20,000 characters. + + + +```ts TypeScript +export default function check({ input, output }) { + const order = input.customer_message.match(/#?(\d{5})/)?.[1]; + if (!order) return { score: null, reason: "No order number in the input" }; + const found = output.includes(order); + return { + score: found ? 1 : 0, + reason: found ? "Has the order number" : "No order number", + }; +} +``` + +```python Python +import re + + +def check(input, output): + match = re.search(r"#?(\d{5})", input["customer_message"]) + if not match: + return {"score": None, "reason": "No order number in the input"} + found = match.group(1) in output + return { + "score": 1 if found else 0, + "reason": "Has the order number" if found else "No order number", + } +``` + + + +The function gets these values: `input`, `output`, `expected`, `metadata`, `latencyMs`, `costUsd`, and `tokens`. In Python, the names are `latency_ms` and `cost_usd`, and the function gets only the arguments that it names, unless it takes `**kwargs`. On live traces, `expected` is null and `metadata` is `{}`. In TypeScript, the function can be `async`. + +The function returns one of these values: + +- A number from 0 to 1. +- `true` or `false`. +- `null` (`None` in Python), for an item that the check does not apply to. The score is then **Not scored**. +- An object with `score` and `reason`. + +A pass or fail check passes when the score is 0.5 or more. + +The code runs in a sandbox on telemetry.dev servers: + +| Limit | TypeScript | Python | +| --- | --- | --- | +| Runtime | QuickJS | CPython 3.12 for WASI, with the standard library | +| Time | 5 seconds | 5 seconds | +| Memory | 64 MB | 128 MB | +| Size of the returned JSON | 64 KB | 64 KB | + +The code has no network access, no file system, no environment variables, and no timers. A TypeScript check cannot `import` packages. If the check takes too long, uses too much memory, or throws an error, the score shows **Judge error** and the cause. + +## Rules + +A rule passes when all of its conditions hold. Select **Add a condition** to add up to 10 conditions. Each condition has a metric, an operator, and a value: + +| Metric | Operators | Value | +| --- | --- | --- | +| **Trace duration** | **is less than**, **is at most**, **is more than**, **is at least** | Seconds | +| **Cost** | Same as above | USD | +| **Output tokens** | Same as above | A count | +| **Output length** | Same as above | Characters | +| **Output contains** | **is true**, **is false** | Text of up to 1,000 characters | +| **Output matches a regular expression** | **is true**, **is false** | A pattern of up to 500 characters | +| **Output is valid JSON** | **is true**, **is false** | None | +| **Output matches a JSON schema** | **is true**, **is false** | A JSON schema of up to 20,000 bytes | +| **A tool was called** | **is true**, **is false** | A tool name | + +If a trace has no value for a metric, such as no cost, the score is **Not scored**. A fail score has a reason, such as "Trace duration is 7.44 s, not less than 2 s." The JSON schema check ignores keywords that it does not know, such as `$ref` and `format`. + +## Human scores + +A human score is a score that persons give. Select the kind of score: **Pass / fail**, **Number** with a **From** and a **To** value, or **Labels**. Under **Who gives it**, select **Reviewers in review queues**, **Members on Trace detail**, or the two. Write a **Guide for reviewers** of up to 20,000 characters, if necessary. + +Read [Review queues](/evals/review-queues) and [Add a score on a trace](/evals/scores#add-a-score-on-a-trace). + +## User feedback + +The **User feedback** evaluator shows the thumbs up and down that your app sends with the SDK. telemetry.dev adds it to the list when the project gets its first `user_feedback` score. You cannot delete it. Read [Send scores from your app](/evals/scores#send-scores-from-your-app). + +## Score live traces + +An LLM judge, a code check, or a rule can score new traces when they arrive. Under **Where it runs**, select **Live traces**, then set the filters: + +| Filter | Choices | +| --- | --- | +| **Span name** | **Whole traces**, or one span name. With a span name, the evaluator scores each span of that name. | +| **Environment** | **Any environment**, or one environment. **Any environment** leaves out `experiment` and `playground`, the environment of prompt test runs. | +| **Sample** | A percentage of traces from 1 to 100. The default is 10. Leave it empty to score each trace. | + +The switch in the row of the evaluator turns live scores on or off. Before you turn on an LLM judge, add a key for the provider of its model. + +These rules apply to live scores: + +- telemetry.dev scores a trace at the earliest 60 seconds after its last span arrived, so that most traces are complete. +- The sample uses the trace ID. A trace is in the sample of an evaluator or out of it, and the evaluator scores each trace or span one time. +- Live scores start when you turn them on. Traces from the time when live scores were off get no live scores. To score them, use [Score past traces](#score-past-traces). +- If the evaluator falls more than 1 hour behind, it skips the older traces. This occurs when it waits for the daily limit or a provider key, or when more traces arrive than it can score. + +### Score past traces + +To score traces that arrived before you turned on live scores, select **Score past traces** in the panel of the evaluator. Live scores must be on. The evaluator then scores the traces of the last 7 days that match its filters and its sample, and that have no score from it. The evaluator scores the traces in batches, so the scores of many traces take some time to show. An LLM judge also waits while the project is at its daily limit. When you make an LLM judge, you can also select **Also score past traces**. The form shows an estimate of the count of traces. For a saved judge with the same model, it also shows the cost. + +### Prompt capture off + +An evaluator that reads content cannot score a trace from an environment with prompt capture off. The score is then **Not scored**, with the reason "Prompt capture is off in production, so the judge cannot read this trace." + +These evaluators read content: + +- An LLM judge whose prompt has `{{input}}` or `{{output}}`. +- A code check. +- A rule with an output condition other than **Output tokens**. + +## Change or delete an evaluator + +Select the evaluator, then **Edit evaluator**. Change the fields, then select **Save changes**. Changes apply to new scores. The scores from before stay. A change of the prompt, the model, the reason setting, the code or its language, the conditions, the guide, or the score settings makes a new version. The trend in the panel marks the day of a new version with a dashed line. + +To delete an evaluator, select **Delete** in its panel, then **Delete evaluator**. Its scores stay on the traces, with its name. You cannot delete an evaluator that an experiment uses. + +## The evaluator panel + +The panel shows these sections: + +- The trend of the last 30 days: the pass rate, the fail rate, or the average, with the change from the 30 days before. +- The configuration: the judge prompt, the code, or the conditions. +- **Runs on**: the live filters, whether experiments select it by default, the cost of the last 7 days for a judge, and the progress of **Score past traces**. +- **Recent fails**: up to 3 traces with a fail score. Select **View all traces** to see all of them on the **Traces** page. + +## Set the daily limit + +Live LLM judges call a model for each trace that they score. The daily limit stops them for the rest of the UTC day when they spent the limit. The default limit is $20. + +To change the limit, open **Settings**, select **Model providers** under the project, and go to **Daily limit for live evaluators**. Enter an amount from $0 to $10,000, then select **Save**. Only owners and admins can change the limit. **Spent today** shows the spend of the day. It resets at 00:00 UTC. + +The limit applies to live LLM judges and to **Score past traces** with an LLM judge. It does not apply to code checks, rules, **Try it**, or experiments. telemetry.dev examines the spend before each call, so the calls in progress can take the spend a little over the limit. When the judges stop, the **Evaluators** tab shows **Live evaluators stopped for today**. + +Your model provider bills the calls of the judges. telemetry.dev calculates the spend from the token counts and the price of the model. A valid score from a model without a price, or from an OpenAI-compatible endpoint, adds $0.01. The **Usage** page of the project settings shows the **Evaluator spend this month** of LLM judges on live and past traces, with the top 10 evaluators. + +## What leaves telemetry.dev + +An LLM judge sends its prompt to the model provider of the judge. The prompt has the content that its variables hold. On live and past traces, this is the stored content of the trace, after its [redaction](/platform/privacy#what-built-in-redaction-removes). In an experiment, it is the dataset item and the output. telemetry.dev keeps the outputs that your code sends as they are, without redaction. Code checks and rules run on telemetry.dev servers and call no model. + +## Limits + +| Limit | Value | +| --- | --- | +| Name | 64 characters | +| Description | 500 characters | +| Judge prompt, code, or guide for reviewers | 20,000 characters | +| Labels | 20, of 64 characters each | +| Conditions of a rule | 10 | +| Daily limit for live evaluators | $0 to $10,000, default $20 | diff --git a/docs/evals/experiments.mdx b/docs/evals/experiments.mdx new file mode 100644 index 0000000..685f45a --- /dev/null +++ b/docs/evals/experiments.mdx @@ -0,0 +1,263 @@ +--- +title: Experiments +description: Run a prompt version or your own code on each item of a dataset, score the outputs, and compare them with the baseline in the dashboard or in CI. +lastModified: 2026-10-30 +--- + +An experiment runs a prompt version or your code on each item of a [dataset](/evals/datasets), then scores each output with [evaluators](/evals/evaluators). The experiment page compares the scores with the baseline of the dataset, so you can see which items became better or worse. + +There are two kinds of experiment: + +- **A prompt version.** telemetry.dev runs a saved version of a prompt of the project on each item. Start it in the dashboard. +- **Your code.** Your code runs each item and sends the outputs with `runExperiment` (TypeScript) or `run_experiment` (Python). Start it from a script or from CI. + +## Run a prompt version + + + + Select **New experiment** on the **Experiments** tab of **Evals**. You can also select **Run experiment** on a dataset page, on a version of a dataset, or on a prompt page. + + + Under **Run**, select **A prompt version**. Select the **Prompt** and the **Version**. Only saved versions can run. The dialog lists the newest 50 versions. + + + Select the **Dataset**, then **All items** or one split under **Items**. The experiment uses the newest version of the dataset. To use an older version, open that version of the dataset and select **Run experiment** there. + + + Under **Model**, keep the model of the prompt, or select a different model to compare models. The **Other models** group lists only the models of providers that have a key in **Model providers**. + + + Set **Runs for each item** (1 to 5, default 1). Under **Evaluators**, select up to 20 LLM judges, code checks, and rules. Under **Compare with**, keep the baseline of the dataset, or select a different completed experiment of the same dataset. + + + Read the estimate of the cost and the time, then select **Run experiment**. The experiment page opens. + + + +The **Name** of the experiment follows the prompt, the version, and the model, such as `reply-v13-gpt-4o`. You can change it. Names are unique in the project. If the name is in use, telemetry.dev adds a number, such as `-2`. + +The keys of the item input become the variables of the prompt. A text value goes in as it is. A different value goes in as JSON. For example, the item input `{"question": "Where is my refund?"}` fills `{{question}}`. If a prompt calls a tool, the tool must have a sample result in the prompt. + +The model calls use the provider key of the project. If the project has no key for the provider of the model, the dialog tells you to add it in **Model providers**. Read [Model provider keys](/evals#model-provider-keys). + +### How telemetry.dev runs the items + +telemetry.dev runs at most 4 items of one experiment at the same time. Each run records a trace in the `experiment` environment, with the root span `experiment `. If a run takes more than 5 minutes, it stops with an error, and the next item starts. + +A run with an error still counts as done, and it gets no scores. The experiment stops with **Failed** in these conditions: + +- The model returns an error for 20 runs in a row. The scores of the runs before the errors stay. +- Each run of the experiment has an error. +- The prompt version is deleted, or the project no longer has a key for the provider. + +The estimate in the dialog comes from earlier experiments of the same prompt and model. With no earlier experiment, it comes from the prices of the model. It includes the cost of the LLM judges. + +## Run your code + +Use `runExperiment` or `run_experiment` when the code under test is more than one prompt, such as an agent with tools. Your code runs on your computer or in CI, and telemetry.dev scores the outputs. + +Before you start, make sure that you have these items: + +- `@telemetry-dev/sdk` 0.2.2 or later, or `telemetry-dev` 0.3.2 or later. +- An API key with **Send telemetry** and **Run experiments** access, in `TELEMETRY_DEV_API_KEY`. Read [API keys](/platform/api-keys). +- A dataset with items in the project of the key. + + + +```ts TypeScript +import { init, runExperiment } from "@telemetry-dev/sdk"; + +init({ environment: "experiment" }); + +const result = await runExperiment({ + name: "reply-v13-gpt-4o", + dataset: "support-golden", + task: (item) => replyToCustomer(item.input), + evaluators: ["correctness", "helpfulness"], + scorers: { short: (output) => String(output).length < 600 }, + minScores: { correctness: 0.9 }, +}); + +console.log(result.url); +``` + +```python Python +import telemetry_dev + +telemetry_dev.init(environment="experiment") + +result = telemetry_dev.run_experiment( + name="reply-v13-gpt-4o", + dataset="support-golden", + task=lambda item: reply_to_customer(item.input), + evaluators=["correctness", "helpfulness"], + scorers={"short": lambda output, item: len(output) < 600}, + min_scores={"correctness": 0.9}, +) + +print(result.url) +``` + + + +In Python, use `run_experiment_async` for an `async` task or scorer. + +The function does these steps: + +1. It reads the newest version of the dataset, or the version in `datasetVersion` (`dataset_version`). With `split`, it reads only the items of that split. +2. It makes the experiment. Without `name`, telemetry.dev selects a name. +3. It calls `task` for each item, 4 items at the same time. Set `concurrency` to 1 to 100 to change this. With `runsPerItem` (`runs_per_item`), each item runs 1 to 5 times. +4. It runs your `scorers` on each output, then sends the outputs to telemetry.dev, at most 100 items at a time. +5. It waits up to 30 minutes for the server evaluators, prints the scores, and returns the result. + +### The task + +`task` gets the item: `id`, `number`, `input`, `expectedOutput` (`expected_output`), `metadata`, `tags`, `split`, and `runIndex` (`run_index`). Its return value is the output. A value that is not a string becomes JSON. The SDK cuts each output at 100,000 characters. + +If the task throws an error, only its item gets an error. The item records the name and the message of the error. Each run gets its own copy of the item, so a task that changes its input does not change the next run. + +Each item run is a trace with the span `experiment `. The SDK puts `td.experiment.id` and `td.dataset.item_id` on each span of the run, also on the spans of the telemetry.dev provider integrations. Spans from the Vercel AI SDK and TanStack AI integrations do not get these attributes. Each run also gets its own session ID. + +### Scores of the experiment + +- `evaluators` names evaluators of the project: LLM judges, code checks, and rules. telemetry.dev runs them on the outputs. The match of the name ignores letter case when only one evaluator matches. +- `scorers` run on your computer, after the span of the item ends. A scorer gets the output and the item. It returns `true` or `false` for a pass or a fail, a number, a label, or an object with `value`, `label`, and `reason`. A scorer cannot have the name of an evaluator of the run, or the name `user_feedback`. +- `minScores` (`min_scores`) sets a pass mark for each score name. For a pass or fail score, the mark is the lowest pass rate, from 0 to 1. For a number score, it is the lowest mean. A score less than its mark makes the check fail. + +If a scorer throws an error or returns a value that is not a score, the item gets no score of that name. The SDK reports a `scorer_failed` error to `onError` (`on_error`). + +### The environment and the key + +Call `init({ environment: "experiment" })` before the run. The `experiment` environment keeps the item traces out of your production pages and metrics. In a different environment, the SDK logs a warning. Without an initialized client, the items record no traces and no cost. + +A key with **Send telemetry** and **Run experiments** access can send telemetry in the `experiment` environment, also when the key is [limited to a different environment](/platform/api-keys#limit-a-key-to-one-environment). + +### The result and errors + +The result has the `status`, the `checkStatus` (`check_status`), the item counts, the `url` of the experiment page, and the `scores`. Each score has its value, the baseline value, the change, and its pass mark. + +A failed request rejects with an `ExperimentError` (Python raises it). Its `code` tells the cause, such as `dataset_not_found`, `dataset_empty`, `evaluator_not_found`, `insufficient_scope`, `missing_api_key`, or `timeout`. The SDK sends a read, a post of outputs, or the completion again up to 2 times. It does this after a timeout, a network error, a `429`, or a `5xx`. It sends the request that makes the experiment again only after a `429`, so a lost response cannot make a second experiment. + +If the function fails after it made the experiment, it first tells telemetry.dev that the run is complete. In Python, this also occurs after `Ctrl-C` or a cancellation. telemetry.dev then ends the experiment with the item runs that it got, or marks it **Failed** when it got none. If the process stops without this step, the experiment ends 24 hours after its last item run. + +:::warning[Outputs ignore the capture settings] +The outputs, the errors of failed tasks, the scorer reasons, and `metadata` go to telemetry.dev and stay with the experiment. `captureOutput`, `mask`, and the prompt capture setting of the environment do not apply to them. They apply only to the spans of the run. +::: + +## Read the results + +The **Experiments** tab lists the experiments of the project, newest first. It shows the **Dataset**, the **Scores** with the change from the baseline of the dataset, the **Cost**, the time it was **Created**, and the **Status**. Use the search and the **All datasets** and **All prompts** filters to find an experiment. + +| Status | Meaning | +| --- | --- | +| A count, such as **64 of 120** | The items run and get scores. Scores show when items finish. | +| **Completed** | All runs are done and scored. A run with an error has no scores. | +| **Baseline** | The experiment is the baseline of its dataset. Other experiments on the dataset compare with it. | +| **Check failed** | A score is less than its pass mark. | +| **Failed** | The experiment stopped because of errors. The page shows the cause. | +| **Stopped** | A person stopped the experiment. The scores of the items that ran stay. | + +Select an experiment to open its page: + +- The details: the dataset, the prompt and the model, or **Your code**, and the time of the run. An experiment from GitHub Actions also shows the pull request and the commit. +- The summary cards: one card for each evaluator, with the pass rate, the mean, or the most frequent label. A pass rate or a mean also shows the change from the compared experiment. The **p50 latency** and **Cost** cards follow. +- The check: if the experiment has pass marks, **The check passed** or **The check failed**, with the score and its mark. +- The items: the **Input**, **Expected**, **Output**, and **Baseline output** of each item, with a column for each score. Select an item to open its outputs, its scores, and the reason of each score. From the item panel, select **Open trace**, **Send to review**, or **Add to dataset**. + +A pass rate counts only the items that got a score. An item with **Not scored** or **Judge error** is not part of the rate. If an LLM judge could not score items, the page shows how many. + +### Regressed and improved items + +When an experiment ends and compares with a different experiment, the filter above the items shows the counts of **Regressed**, **Improved**, and **Unchanged** items: + +- **Regressed**: at least one evaluator gave the item a worse score. +- **Improved**: no evaluator gave a worse score, and at least one gave a better score. +- **Unchanged**: no score changed. + +A pass or fail score compares whether half or more of the runs of the item pass. A number score must change by at least 1, or by at least 0.1 on a scale of 1 or less. Label scores, and items without a score on the two sides, count as unchanged. + +To let reviewers look at the regressed items, select **Send regressions to review**. Read [Send regressions to review](/evals/review-queues#send-regressions-to-review). + +## Compare experiments + +Each dataset has one baseline. A new experiment compares with the baseline by default. To make a completed experiment the baseline, select **Set as baseline** in its row menu. Experiments that started before the change keep their comparison. + +On the experiment page, use **Compare with** to compare with a different completed experiment of the same dataset, or with nothing. + +To see two experiments side by side, select **Compare with…** in the row menu of an experiment, then select the other experiment. The **Compare experiments** page shows the scores and the cost of **A** and **B**, and the outputs of each item next to each other. Items match by dataset item, so the two experiments must use the same dataset. + +## Run experiments in CI + +When the `CI` variable is `true` or `1`, or with `ci: true` (`ci=True`), the SDK runs in CI mode. The function then rejects (Python raises) when the check fails (`check_failed`) or when the experiment does not complete (`experiment_failed`). As a result, the process exits with an error. In GitHub Actions, the experiment also records the repository, the commit, the run, and the pull request. + +The `telemetry-dev/telemetry/actions/experiment` action runs your eval script in a GitHub Actions workflow. It writes the result to the job summary and to a comment on the pull request. + +```yaml +on: pull_request + +permissions: + contents: read + pull-requests: write + +jobs: + evals: + # Pull requests from forks get no secrets, so the job runs only for branches of this repository. + if: github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + env: + TELEMETRY_DEV_API_KEY: ${{ secrets.TELEMETRY_DEV_API_KEY }} + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: 24 + - run: npm ci + - uses: telemetry-dev/telemetry/actions/experiment@main + with: + dataset: support-golden + script: evals/reply.eval.ts + min-scores: correctness=0.9 +``` + +| Input | Description | +| --- | --- | +| `script` | The eval script. A `.ts`, `.mts`, `.cts`, or `.tsx` script runs with the `tsx` of your project, so add `tsx` to your `devDependencies`. A `.js`, `.mjs`, or `.cjs` script runs with `node`, and a `.py` script with `python`. | +| `command` | A shell command that runs the eval script, such as `uv run python evals/reply_eval.py`. Give `script` or `command`. | +| `dataset` | The dataset. If the script also names a dataset, the two names must be the same. | +| `min-scores` | Pass marks as `name=value` pairs, separated by commas or new lines. For the same name, they replace the `minScores` of the script. | +| `api-key` | The API key. The default is the `TELEMETRY_DEV_API_KEY` variable of the job. | +| `base-url` | The default is `https://api.telemetry.dev`. | +| `working-directory` | The directory of the script or the command. The default is `.`. | +| `comment` | Set to `false` to write only the job summary. | +| `github-token` | The token that writes the comment. The default is `github.token`, which must have the `pull-requests: write` permission. | + +The action sets `TELEMETRY_DEV_ENVIRONMENT` to `experiment` if the job does not set it. It has two outputs: `check-status` (`passed`, `failed`, or `none`) and `url`. The job fails when the script exits with an error. In CI mode, the SDK makes the script exit with an error when the check fails or when the experiment does not complete, unless the script catches the error. + +The comment shows the status of each experiment and the count of items that ran. Its table of scores has the **Value**, the **Change**, and the **Pass mark** of each score. The action writes one comment for each workflow, job, and input, and changes that comment on each later push. + +To keep a workflow the same when `main` changes, use a commit SHA of `telemetry-dev/telemetry` in place of `@main`. + +## Stop, run again, or delete an experiment + +- To stop an experiment that runs, select **Stop** on its page. In a prompt experiment, the items that did not start close without an output, and the runs in progress finish and keep their scores. An experiment of your code takes no more runs, and its next post of runs gets `409 experiment_ended`. +- To run a prompt experiment again, select **Run again** in its row menu. The **New experiment** dialog opens with the settings of the experiment. An experiment of your code runs again from your code. +- To delete an experiment, select **Delete experiment** in its row menu. Its outputs and their scores go with it. The traces of its runs stay. You cannot delete an experiment while it runs. + +## Cost + +The model calls of a prompt experiment and its LLM judges use the provider keys of the project, and your provider bills them. The **Cost** card adds up the cost of the item runs. For your code, it uses the `costUsd` of each run, or the cost of the trace of the run when the run has no `costUsd`. The card does not include the cost of the LLM judges, but the estimate in the **New experiment** dialog does. + +Experiments do not count toward the [daily limit for live evaluators](/evals/evaluators#set-the-daily-limit), and the limit does not stop them. + +## Limits + +| Limit | Value | +| --- | --- | +| Name | 128 characters | +| Runs for each item | 5 | +| Evaluators in one experiment | 20 | +| Pass marks | 20 | +| Items | The items of one dataset version, at most 10,000 | +| Output of an item from your code | 100,000 characters | +| Runs of one experiment at the same time | 4 for a prompt experiment, 1 to 100 (default 4) for your code | +| Time of one run of a prompt experiment | 5 minutes | diff --git a/docs/evals/index.mdx b/docs/evals/index.mdx new file mode 100644 index 0000000..ddf8766 --- /dev/null +++ b/docs/evals/index.mdx @@ -0,0 +1,89 @@ +--- +title: Evals +description: Test prompts and models on datasets, score live traces with LLM judges, code checks, and rules, and review replies with your team. +sidebar: { label: "Overview" } +lastModified: 2026-10-30 +--- + +Evals measures the quality of the replies of your AI application. You keep test items in datasets and run a prompt version or your code on each item. Then you compare the scores with the scores of an earlier run. The same evaluators can also score the traces of your users when they arrive. + +Select **Evals** in the project sidebar. The page has four tabs: + +| Tab | Contents | +| --- | --- | +| **Experiments** | Runs of a prompt version or of your code on a dataset, with the output and the scores of each item. | +| **Datasets** | Test items. Each item has an input, an optional expected output, metadata, tags, and a split. | +| **Evaluators** | The sources of scores: LLM judges, code checks, rules, human scores, and the feedback of your users. | +| **Review** | Review queues, where persons score traces and write better replies. | + +## How the parts work together + +1. **Collect test items.** Add traces with bad replies to a dataset, import a CSV file, or add items by hand. Read [Datasets](/evals/datasets). +2. **Make evaluators.** An LLM judge reads the reply and gives a score with a reason. A code check or a rule gives a score without a model. Read [Evaluators](/evals/evaluators). +3. **Run an experiment.** Run a saved prompt version from the dashboard, or run your own code with the SDK. Each item gets an output and its scores. Read [Experiments](/evals/experiments). +4. **Compare.** The experiment page compares each score with the baseline of the dataset and marks the items that became worse. +5. **Score live traffic.** Turn on **Live traces** for an evaluator to score a sample of new traces. You can also send the thumbs up or down of your users from your app. Read [Scores](/evals/scores). +6. **Review.** Send traces to a review queue. Reviewers give scores, and their expected outputs can become dataset items. Read [Review queues](/evals/review-queues). + +To stop a regression before you merge it, run the experiment in CI. Read [Run experiments in CI](/evals/experiments#run-experiments-in-ci). + +## Model provider keys + +Experiments of a prompt version and LLM judges call models with the keys of the project. Your model provider bills these calls. Code checks and rules do not call a model. + +To add a key: + + + + Open **Settings**, then select **Model providers** under the project in the settings sidebar. + + + In the row of the provider, select **Add key**. For an OpenAI-compatible endpoint, select **Add endpoint** and enter its **Base URL**. + + + Enter the **API key**, then select **Add key** or **Add endpoint**. + + + +The providers are OpenAI, Anthropic, Google, and one OpenAI-compatible endpoint. Only owners and admins can add, change, or remove a key. After you save a key, nobody can read it. + +Your app keeps its own provider keys. telemetry.dev uses the keys on this page only for test runs of prompts, **Suggest changes** in the prompt editor, experiments, and LLM judges. + +## The experiment environment + +A prompt experiment records each item run as a trace in the `experiment` environment. The SDKs record the runs of your code in the environment of the client, so call `init` with `environment: "experiment"` before the run. The **Overview**, **Traces**, and **Sessions** pages leave out this environment by default. To see the traces of experiment runs, select `experiment` in the **Environment** filter of **Traces** or **Sessions**. Live evaluators and review queue rules also leave out `experiment`, unless you select it in their filters. + +The traces of experiment runs count as ingestion units, as other traces do. + +## Who can do what + +Each member of the workspace can make, change, and delete datasets, experiments, evaluators, and review queues. Each member can also add scores on a trace. + +Only owners and admins can do these tasks: + +- Add or change model provider keys. +- Set the [daily limit for live evaluators](/evals/evaluators#set-the-daily-limit). +- Make API keys. Read [API keys](/platform/api-keys). +- Turn on or change alerts, such as [Eval score drop](/platform/alerts#eval-score-drop). + +Evals is available on each plan. + +## Use Evals from code + +An API key with the **Run experiments** access can read datasets, run experiments, and send scores. The SDKs have these functions: + +| Task | TypeScript (`@telemetry-dev/sdk` 0.2.2 or later) | Python (`telemetry-dev` 0.3.2 or later) | +| --- | --- | --- | +| Run your code on a dataset | `runExperiment` | `run_experiment`, `run_experiment_async` | +| Send a score, such as user feedback | `score` | `score`, `score_async` | + +Other languages can use the HTTP API. Read [Evals API](/reference/evals-api). + + + Collect test items from traces, CSV files, and review queues. + Run a prompt version or your code on a dataset and compare the scores. + Score replies with LLM judges, code checks, rules, and persons. + Read scores on traces, filter by them, and send user feedback. + Let persons score traces and write expected outputs. + Read datasets, run experiments, and send scores over HTTP. + diff --git a/docs/evals/meta.ts b/docs/evals/meta.ts new file mode 100644 index 0000000..f102831 --- /dev/null +++ b/docs/evals/meta.ts @@ -0,0 +1,8 @@ +import { defineMeta } from "blume"; + +export default defineMeta({ + title: "Evals", + icon: "flask-conical", + order: 6, + pages: ["index", "datasets", "experiments", "evaluators", "scores", "review-queues"], +}); diff --git a/docs/evals/review-queues.mdx b/docs/evals/review-queues.mdx new file mode 100644 index 0000000..b4504c1 --- /dev/null +++ b/docs/evals/review-queues.mdx @@ -0,0 +1,127 @@ +--- +title: Review queues +description: Send traces to a review queue, let reviewers give scores and better replies, and add the good replies to a dataset. +lastModified: 2026-10-30 +--- + +A review queue is a list of traces for persons to score. The scores of reviewers show on the traces, next to the scores of the LLM judges. When a reviewer writes a better reply, the trace can become a [dataset](/evals/datasets) item with that reply as its expected output. + +To see the queues of a project, select **Evals** in the project sidebar, then the **Review** tab. The tab shows a count of the items that you can review. The list shows the **Progress**, the **Scores**, and the **Reviewers** of each queue. + +## Make a queue + +A queue asks for human scores, a better reply, or the two. To ask for a score, first make a human score with **Reviewers in review queues** selected. Read [Human scores](/evals/evaluators#human-scores). + + + + On the **Review** tab, select **New queue**. + + + Enter a **Name** of up to 128 characters. Enter optional **Instructions** of up to 4,000 characters. Reviewers see them next to each trace. + + + Under **Scores to ask for**, select up to 20 human scores, **Expected output**, or the two. **Expected output** asks reviewers for a better reply. + + + Under **How traces come in**, select **By hand** or **By a rule**. Read [Add traces by a rule](#add-traces-by-a-rule). + + + Select up to 100 **Reviewers** from the members of the workspace. Leave the field empty to let each member review. Set **Reviews for each trace** (default 1). It cannot be more than the count of reviewers. + + + Under **Add good replies to**, select a dataset, or **No dataset**. If the queue asks for **Expected output**, you must select a dataset. + + + Select **Create queue**. + + + +Queue names are unique in the project. + +## Add traces by hand + +Send a trace to a queue from one of these places: + +- A trace: select **Add to review queue** in the header. +- **Traces**: select the check boxes of up to 100 rows, then select **Add to review queue**. +- A session: select **Add to review queue** in the header. The full session becomes one item. +- An item of an experiment: select **Send to review** in the item panel. + +In the dialog, select the **Queue**, and enter an optional **Note for the reviewer** of up to 2,000 characters. Then select **Add to queue**. + +A trace or a session can be in a queue one time in each cycle of the queue. An experiment item can be in a queue one time only. telemetry.dev skips the traces that the queue has, and the toast tells you how many. + +## Add traces by a rule + +A queue with a rule gets a random sample of traces each week. Set the rule with these fields: + +- A span name, an environment, and a score, in the menus **Any span name**, **Any environment**, and **Any score**. Select at least one. The score menu has the pass, fail, and label values of the LLM judges, code checks, and rules of the project, such as "Correctness is Fail". +- The count of traces in each sample, from 1 to 100. The default is 40. +- The day of the week, such as **Each Monday**. + +telemetry.dev examines the rules every 5 minutes. A new rule takes its first sample within about 5 minutes. Later samples come at the first examination after 00:00 UTC on the day that you select. Each sample has traces from the 7 days before the run that match the rule. The sample leaves out the traces that the queue had before, and the `experiment` and `playground` environments, unless the rule selects one of them. + +Each sample starts a new cycle of the queue. Open items from the cycle before come first. If no trace matches, the queue keeps its current cycle. + +## Send regressions to review + +When an experiment compares with a different experiment and has regressed items, its page shows **Send regressions to review**. Read [Regressed and improved items](/evals/experiments#regressed-and-improved-items). + +Select **Send regressions to review**, then select **A new queue** or **An existing queue**. A new queue gets the name "\ regressions" and asks for **Expected output** by default. Its reviewers are the members of the workspace, with 1 review for each item. It adds good replies to the dataset of the experiment. + +The reviewer sees the input, the expected output, the output, and the baseline output of each item. + +## Review the items + +Select **Start** in the row of a queue. A queue can have a list of reviewers. If you are not on the list, the page tells you to ask the person who made the queue. + +The page shows one item at a time: + +- The **Note** of the person who added the item. +- The conversation of the trace: the user messages, the tool calls with their results, and the reply. +- The scores of LLM judges, code checks, and rules, with their reasons. +- **Your scores**, with the instructions of the queue. + +To review an item: + +1. Give a value for each score. Each score is necessary. +2. If the queue asks for it, enter a better reply in **Expected output**. +3. Enter an optional **Comment** of up to 4,000 characters. The comment becomes the reason of each score. +4. Select **Submit and next**, or press `⌘` `Enter` (`Ctrl` `Enter` on Windows and Linux). + +Select **Skip** to go to the next item. A skipped item goes away for you only. Other reviewers still get it. + +Session items have no **Expected output** and cannot go to a dataset. For other items, when you write an expected output, the box **Add this trace to \** becomes selected. On submit, the trace becomes a dataset item with the expected output that you wrote. If you select the box and leave **Expected output** empty, the reply of the trace becomes the expected output. + +### The order of the items + +Items come in the order that persons added them. In a queue with a list of reviewers, each reviewer gets a share of each add. When reviewers finish their share, they help with the shares of others. In a queue that each member can review, members start on different items. + +You keep the same item until you submit it or skip it. Two reviewers can get the same item. If the other reviews complete the item before you submit, telemetry.dev rejects your submit with "Someone else reviewed this item while you had it open". The page then opens the next item. + +### When the queue is done + +When no items are left for you, the page shows the count of reviewed traces, and the pass rate or the average of each pass or fail score and number score. It also shows how many items went to the dataset. A queue with a rule shows the day of its next sample. Select **View the scored traces** to open the **Traces** page, or **View the experiment** for a queue of experiment items. + +## Change or delete a queue + +Open the row menu of the queue on the **Review** tab: + +- Select **Edit queue** to change the queue. Then select **Save queue**. If you decrease **Reviews for each trace**, open items that have the new count of reviews close. +- Select **Delete queue** to delete the queue and its items. The scores that reviewers gave stay on their traces. + +Each member of the workspace can make, change, and delete queues. + +## Limits + +| Limit | Value | +| --- | --- | +| Name | 128 characters | +| Instructions | 4,000 characters | +| Scores to ask for | 20 | +| Reviewers | 100 | +| Reviews for each trace | 1 to 100, and not more than the count of reviewers | +| Traces in one add | 100 | +| Traces in one sample of a rule | 1 to 100 | +| Note for the reviewer | 2,000 characters | +| Comment of a reviewer | 4,000 characters | diff --git a/docs/evals/scores.mdx b/docs/evals/scores.mdx new file mode 100644 index 0000000..365ae74 --- /dev/null +++ b/docs/evals/scores.mdx @@ -0,0 +1,132 @@ +--- +title: Scores +description: Read the scores of traces and sessions, filter traces by a score, add scores by hand, and send the feedback of your users from your app. +lastModified: 2026-10-30 +--- + +A score is one result on a trace, a span, a session, or an experiment item. Scores come from [evaluators](/evals/evaluators), from reviewers in [review queues](/evals/review-queues), from members on the trace page, and from your app. + +## Kinds of scores + +| Kind | Values | Shown as | +| --- | --- | --- | +| Pass / fail | The label `pass` with the value 1, or `fail` with 0 | **Pass** or **Fail** | +| Number | A number in the range of the evaluator, such as 1 to 5 | The number, such as "4 / 5" | +| Labels | One label of the evaluator | The label | +| Up / down | 1 for up, 0 for down | A thumb with **Up** or **Down** | + +A score can also show one of these statuses: + +- **Not scored**: the evaluator did not apply, such as a code check that returned `null`, or a trace from an environment with prompt capture off. +- **Judge error**: the evaluator returned an error, such as a provider error. + +Pass rates and averages count only the scores with a value. They do not count **Not scored** and **Judge error**. + +## Read scores on a trace + +Open a trace and select its root span. The **Scores** section of the span panel shows the scores of the trace and of the span. A different span shows the section only when it has scores of its own. + +Each row shows the name of the score, the value, the source, and the reason or the comment. The source is one of these: + +- The model of an LLM judge, such as "gpt-4o-mini judge". +- **Code check** or **Rule**. +- The reviewer of a review queue, such as "Maya Chen · review queue". +- The name of the member who added the score on the trace page. +- **From your app**, for a score from the SDK or the API. + +## Add a score on a trace + +Members can add a human score on a trace. The evaluator must be a human score with **Members on Trace detail** selected. Read [Human scores](/evals/evaluators#human-scores). + + + + Open the trace, then select **Add score** in the **Scores** section. + + + Select the **Score**, then the **Value**. Enter an optional **Comment** of up to 4,000 characters. + + + Select **Save score**. + + + +The score goes on the span that you look at. If you add the same score again on the same span, your new score replaces your earlier score. + +Only the person who added a score on the trace page can remove it. To remove it, select **Remove score** in its row. You cannot remove scores from evaluators, review queues, or your app. + +## Read scores on a session + +The session page shows the newest score of each name on the session. These include the scores that your app sent with only a session ID, and the reviews of the session. Each turn shows a summary of the scores of its trace. + +## Filter traces by a score + +The trace list on the **Traces** page has a **Scores** column. Each cell shows one score and its value, and **+N** for the other scores of the trace. Hover over **+N** to see the names of all of them. A trace can have more than one pass or fail score of the same name, such as from two reviewers. The cell then shows the pass rate. + +To filter by a score, select a value in the **Scores** column, such as **Fail**. A chip above the table shows the filter, such as "Correctness Fail". Select the chip to clear the filter. You can filter by a pass or fail value, an up or down value, or a label. + +The filter has these limits: + +- It reads the newest 1,000 scores that match. When more scores match, the list says that traces with older scores do not show. +- It counts only scores with a value. +- It leaves out experiment runs, unless the **Environment** filter is `experiment`. +- The **Spans** view has no score filter. + +A score from your app with a name that no evaluator has shows its number or label, and you cannot filter by it. + +## Send scores from your app + +Use `score` to record a score on a trace, a span, or a session. For example, send the thumbs up or down of a user on a reply: + + + +```ts TypeScript +import { score, startActiveSpan } from "@telemetry-dev/sdk"; + +// When the app replies, keep the trace ID of the reply with the message. +const reply = await startActiveSpan("reply", async (span) => ({ + text: await replyToCustomer(message), + traceId: span.traceId, +})); + +// Later, when the user selects thumbs down: +await score({ name: "user_feedback", traceId: reply.traceId, value: 0, comment: "Wrong amount" }); +``` + +```python Python +import telemetry_dev + +# When the app replies, keep the trace ID of the reply with the message. +with telemetry_dev.start_span("reply") as span: + text = reply_to_customer(message) + trace_id = f"{span.span.get_span_context().trace_id:032x}" + +# Later, when the user selects thumbs down: +telemetry_dev.score(name="user_feedback", trace_id=trace_id, value=0, comment="Wrong amount") +``` + + + +`score` is in `@telemetry-dev/sdk` 0.2.2 or later, and in `telemetry-dev` 0.3.2 or later. The API key must have **Run experiments** access. Call `score` from your server. Do not put the key in a browser. + +- Give `traceId` (`trace_id`), `sessionId` (`session_id`), or the two. To score one span, also give its `spanId` (`span_id`). +- Give `value`, `label`, or the two. A pass or fail score has the label `pass` with the value 1, or `fail` with 0. +- `user_feedback` takes the value 1 for up or 0 for down, and no label. The first `user_feedback` score of a project adds the **User feedback** evaluator. +- A score can have a `comment` of up to 4,000 characters. telemetry.dev applies the [redaction](/platform/privacy#what-built-in-redaction-removes) of the project to the comment. + +`score` does not throw errors into your code. It returns the ID of the score, or `undefined` (`None` in Python) after it reports a `ScoreError`. The error goes to the `onError` (`on_error`) of the client, or to the SDK log when no client is initialized. It makes one request, with no retry. In TypeScript, it waits 10 seconds at most. In Python, `score_async` runs the request in a worker thread. + +Each call adds a new score. telemetry.dev does not merge a score with an earlier score of the same name. It also does not examine whether the trace exists. + +To send a score from a different language, use `POST /v1/scores`. Read [Send a score](/reference/evals-api#send-a-score). + +## Get an alert when a pass rate falls + +The **Eval score drop** alert sends an email when the pass rate of a pass or fail evaluator over 6 hours becomes less than a limit. Read [Eval score drop](/platform/alerts#eval-score-drop). + +## Scores of prompt versions + +The **Metrics** tab of a prompt shows two scores for each version of the prompt: the pass rate of a live pass or fail evaluator, and the **User feedback**. Versions newer than the `production` version show the change from it. The tab counts only scores of live traces, not of experiment runs. + +## Retention + +Scores of traces and sessions follow the retention of the project. When retention deletes a trace, telemetry.dev also deletes its scores. A score without a trace, such as a score of a session, expires by the time that telemetry.dev got it. Scores of experiment items stay with their experiment. Read [Set retention](/platform/privacy#set-retention). diff --git a/docs/index.mdx b/docs/index.mdx index 65b7840..cb8415c 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -2,7 +2,7 @@ title: telemetry.dev documentation description: Send your first AI trace, then connect the provider, framework, or coding agent you already use. sidebar: { label: "Introduction", order: 0 } -lastModified: 2026-10-26 +lastModified: 2026-10-30 seo: title: "LLM Observability Documentation" description: "Docs for telemetry.dev, OpenTelemetry-native observability for AI apps. Send your first trace, then connect your model provider, framework, or coding agent." @@ -39,12 +39,14 @@ telemetry.dev is built on OpenTelemetry. The SDKs send standard OTLP/HTTP, and s - **Follow a conversation.** Traces that share a session ID are grouped into one session. - **Track cost and usage.** Tokens and cost are calculated per span and added up per trace, session, model, and user. - **Keep sensitive data out.** Turn off prompt and response capture per environment, and redact secrets and personal data before storage. +- **Measure quality.** Run a prompt version or your code on a dataset, score the replies with LLM judges, code checks, and reviewers, and compare the results. ## Platform Search traces, read the span waterfall, and follow sessions. Requests, cost, p95 latency, tokens, and error rate over time. + Datasets, experiments, evaluators, scores, and review queues. Control what is captured, redact sensitive values, and set retention. Endpoints, authentication, limits, and error responses. diff --git a/docs/platform/alerts.mdx b/docs/platform/alerts.mdx index 387a45a..f4d98c5 100644 --- a/docs/platform/alerts.mdx +++ b/docs/platform/alerts.mdx @@ -1,14 +1,14 @@ --- title: Alerts -description: Get an email when model cost, traces, model or tool failures, ingestion errors, or quota usage need attention. -lastModified: 2026-10-28 +description: Get an email when model cost, traces, model or tool failures, eval scores, ingestion errors, or quota usage need attention. +lastModified: 2026-10-30 --- -Alerts check your telemetry every 5 minutes and email you when something needs attention: model cost heading over budget, a trace that might be an agent loop, a burst of failed model or tool calls, or ingestion that is failing or running out of quota. +Alerts check your telemetry every 5 minutes and email you when something needs attention: model cost heading over budget, a trace that might be an agent loop, a burst of failed model or tool calls, a drop in the pass rate of an evaluator, or ingestion that is failing or running out of quota. There are two places to set them up: -- **Project alerts** cover cost, traces, model and tool calls, and ingestion errors for one project. Select **Alerts** in the project sidebar. The page has three tabs: **Rules**, **History**, and **Destinations**. +- **Project alerts** cover cost, traces, model and tool calls, eval scores, and ingestion errors for one project. Select **Alerts** in the project sidebar. The page has three tabs: **Rules**, **History**, and **Destinations**. - **Workspace alerts** cover quota and the mix of data the whole workspace sends. Open **Workspace settings**, select **Usage** in the settings sidebar, and go to the **Alerts** section. Workspace owners and admins can create and change alerts. Other members can see the alerts but cannot change them. Alerts are available on every plan. @@ -17,7 +17,7 @@ Workspace owners and admins can create and change alerts. Other members can see The **Rules** tab lists every kind of project alert, and the workspace's **Alerts** section lists the workspace alerts. Each row says in one sentence when the alert opens. -To turn an alert on, select its switch. It starts with the defaults listed below and checks within 5 minutes. **Monthly budget** has no default budget, so its switch opens the settings instead; enter a budget and select **Turn on**. A project with no alerts also shows **Turn on 6 alerts**, which turns on six recommended alerts with their default limits. A project that already has other alerts and a destination, but no **Tool errors** alert, shows owners and admins **New: Tool errors**; select **Turn on Tool errors** to add it with its defaults and the project's email recipients. Adding it does not change the other alerts. Turning **Tool errors** off removes the prompt. +To turn an alert on, select its switch. It starts with the defaults listed below and checks within 5 minutes. **Monthly budget** has no default budget, so its switch opens the settings instead; enter a budget and select **Turn on**. **Eval score drop** has no default evaluator, so its switch also opens the settings. A project with no alerts also shows **Turn on 6 alerts**, which turns on six recommended alerts with their default limits. A project that already has other alerts and a destination, but no **Tool errors** alert, shows owners and admins **New: Tool errors**; select **Turn on Tool errors** to add it with its defaults and the project's email recipients. Adding it does not change the other alerts. Turning **Tool errors** off removes the prompt. To change an alert's settings, select its row on the **Rules** tab, or its name in the workspace's **Alerts** section. Edit the fields under **Alert when** and select **Save changes**. **Current data** runs the alert against your current telemetry and says whether it would alert now (**Would alert now**, **All clear now**, or **Needs more data**), with the measurement an email would report. It sends no email. @@ -114,6 +114,16 @@ Opens when telemetry.dev records at least that many diagnostics with the same [d Opens when fewer than the minimum share of model calls with token usage have a cost. When the last hour has fewer calls than **Minimum calls**, the rule uses the last 6 hours. A call usually has no cost because telemetry.dev has no price for its model; see [Cost](https://telemetry.dev/docs/reference/cost). +### Eval score drop + +**Settings:** the **Evaluator**, the **Environment** (default `production`), the lowest pass rate in percent (default 85), and **Minimum scored traces** (default 50). + +Watches the scores of one pass or fail evaluator on traces. Read [Evaluators](/evals/evaluators). The rule counts the traces that started in the last 6 hours and got a score with a value from the evaluator. A trace fails when one of its scores from the evaluator is a fail. The scores of experiment items do not count. + +The rule opens when the pass rate of these traces is less than the limit. With fewer scored traces than **Minimum scored traces**, the rule shows **Needs more data**. If someone deletes the evaluator, or changes it so that it no longer gives pass or fail scores of traces, the rule also shows **Needs more data** and tells you to select a different evaluator. + +**Investigate** opens the traces of the last 7 days in the environment that have a fail score from the evaluator. + ## Workspace alerts @@ -150,11 +160,11 @@ Each check reports every rule as breached, healthy, or still needing more data. - **Resolving.** An alert resolves after three healthy checks in a row, about 15 minutes. Recipients get a resolved email if they got the opening email. - **Quiet period.** For 30 minutes after an alert resolves, the same thing opening again still appears on the page, but its opening email is held. It goes out on the first check after the 30 minutes if the alert is still breached. An alert that resolves before then sends no email. The quiet period applies only to the thing that resolved: a different environment, model, or trace opening in that time is emailed as usual. Immediate opens are not held. -A rule can have several alerts open at once, one for each thing it watches: each environment for a budget, each provider and model for model failures, each tool and error type for tool failures, each diagnostic code and API key environment for ingestion errors. +A rule can have several alerts open at once, one for each thing it watches: each environment for a budget, each provider and model for model failures, each tool and error type for tool failures, each diagnostic code and API key environment for ingestion errors. An **Eval score drop** rule watches one evaluator in one environment, so it has at most one open alert. ### Needs more data -Rules that compare with your usual traffic need history before they can decide. **Cost per trace jump**, **Model errors**, and **Tool errors** need at least 7 comparable hours from the last 30 days, and **Data mix shift** needs 7 samples of the same hour of the day. **Missing prices** needs at least **Minimum calls** calls in the last 6 hours, and **Monthly budget** needs the first 24 hours of the month. Until then the rule shows **Needs more data**, except that **Model errors** and **Tool errors** can open without history when half or more of the calls fail, subject to their count minimums. An existing model or tool failure alert can recover when fewer than 10 calls fail, including when traffic stops. +Rules that compare with your usual traffic need history before they can decide. **Cost per trace jump**, **Model errors**, and **Tool errors** need at least 7 comparable hours from the last 30 days, and **Data mix shift** needs 7 samples of the same hour of the day. **Missing prices** needs at least **Minimum calls** calls in the last 6 hours, **Eval score drop** needs at least **Minimum scored traces** scored traces in the last 6 hours, and **Monthly budget** needs the first 24 hours of the month. Until then the rule shows **Needs more data**, except that **Model errors** and **Tool errors** can open without history when half or more of the calls fail, subject to their count minimums. An existing model or tool failure alert can recover when fewer than 10 calls fail, including when traffic stops. A rule with nothing to judge is **All clear**, not **Needs more data**. For example, **Model errors** is all clear when no calls are failing at all. @@ -171,7 +181,7 @@ Each email has these sections: - **Why it matters**: what the problem means for your application or bill. - **Likely cause**: the model, provider, agent, or error that contributed most, when telemetry.dev can tell. -The **Investigate** button opens the page to start from: the project overview, the trace itself for a runaway trace, the failed spans of the model or tool for model and tool errors, the project's **Setup** page for ingestion errors, or the workspace's **Usage** or **Billing** settings for quota. When the rule watches one environment, the spans are filtered to it. A name longer than 128 characters is left out of the filter. +The **Investigate** button opens the page to start from: the project overview, the trace itself for a runaway trace, the failed spans of the model or tool for model and tool errors, the project's **Setup** page for ingestion errors, the traces with a fail score of the evaluator for an eval score drop, or the workspace's **Usage** or **Billing** settings for quota. When the rule watches one environment, the spans are filtered to it. A name longer than 128 characters is left out of the filter. ## Alert history diff --git a/docs/platform/api-keys.mdx b/docs/platform/api-keys.mdx index abb07fa..93ef8c8 100644 --- a/docs/platform/api-keys.mdx +++ b/docs/platform/api-keys.mdx @@ -1,10 +1,10 @@ --- title: API keys description: Create a project key, select its access, limit it to one environment, and revoke it. -lastModified: 2026-10-29 +lastModified: 2026-10-30 --- -An API key lets an application send traces, logs, and metrics to one project. A key can also let the application get the prompts of the project. Each key starts with `td_live_`. +An API key lets an application send traces, logs, and metrics to one project. A key can also let the application get the prompts of the project, run experiments, and send scores. Each key starts with `td_live_`. A workspace owner or admin can create and revoke keys. Members can see the key list. @@ -18,7 +18,7 @@ A workspace owner or admin can create and revoke keys. Members can see the key l Select **Create key**. Enter an optional **Name** of up to 50 characters and an optional **Environment**. - Under **Access**, select **Send telemetry**, **Read prompts**, or the two. At first, the dialog selects the two. A key must have at least one. Read [Select the access of a key](#select-the-access-of-a-key). + Under **Access**, select **Send telemetry**, **Read prompts**, **Run experiments**, or more than one. At first, the dialog selects all three. A key must have at least one. Read [Select the access of a key](#select-the-access-of-a-key). Select **Create key**. In the **API key created** dialog, select **Copy**, then **Done**. @@ -31,7 +31,7 @@ telemetry.dev shows the full key one time. It stores only a SHA-256 hash of the If the **API key created** dialog shows **This key has more access than you chose**, the key has access that you did not select. To limit the access, revoke the key and make a new key. -The project's **Setup** page can also create a key. That key is named after the integration you choose, such as `OpenAI`. This key has **Send telemetry** and **Read prompts**. +The project's **Setup** page can also create a key. That key is named after the integration you choose, such as `OpenAI`. This key has all the access choices. The key list shows each key's **Name**, the first 16 characters of the **Key**, its **Environment** (or **All environments**), its **Access**, its **Status** (**Active** or **Revoked**), and when it was **Created**. For a key with all the access choices, **Access** shows **All**. For a different key, it shows the names of its choices, such as **Read prompts**. @@ -41,10 +41,11 @@ The key list shows each key's **Name**, the first 16 characters of the **Key**, | --- | --- | --- | | **Send telemetry** | Send traces, logs, and metrics to the ingest service. The API name of this scope is `telemetry:write`. | Telemetry from the telemetry.dev SDKs and integrations, and from an OTLP/HTTP exporter. | | **Read prompts** | Get the prompts of the project from the ingest service. The API name of this scope is `prompts:read`. | An app that gets prompts from telemetry.dev. | +| **Run experiments** | Read the datasets of the project, run experiments, and send scores. The API names of these scopes are `datasets:read`, `experiments:write`, and `scores:write`. | `runExperiment` and `run_experiment`, `score`, and the [Evals API](/reference/evals-api). | -If your app sends telemetry and gets prompts with the same key, the key must have the two access choices. +If your app uses one key for more than one task, the key must have each necessary access choice. For example, `runExperiment` reads the dataset with **Run experiments** and sends the traces of the items with **Send telemetry**. -Keys that were made before the **Access** choices were available have the two choices. You cannot change the access of a key. To change the access, make a new key with the necessary access. Put the new key in your app, then revoke the old key. +Keys that were made before the **Access** choices were available have all the access choices. Keys that were made before **Run experiments** was available also got **Run experiments**, also when they had only **Send telemetry** or only **Read prompts**. You cannot change the access of a key. To change the access, make a new key with the necessary access. Put the new key in your app, then revoke the old key. ### A key without the necessary access @@ -52,6 +53,7 @@ If a key does not have the access for a request, the request gets `403 insuffici - Without **Send telemetry**, the ingest service rejects the request. telemetry.dev stores no data from the request and records the rejection on the project with the diagnostic code `insufficient_scope`. - Without **Read prompts**, the ingest service rejects a request for a prompt. The JSON body has the error code `insufficient_scope`. +- Without **Run experiments**, the ingest service rejects a request to read a dataset, run an experiment, or send a score. The JSON body has the error code `insufficient_scope`. To correct the error, make a key with the necessary access. Put the new key in your app, then revoke the old key. @@ -81,6 +83,8 @@ In both cases, the ingest service rejects the request with `403 environment_mism Telemetry without an environment attribute is accepted and gets the key's environment. Read [Set the environment](/platform/environments#set-the-environment). +A key with **Send telemetry** and **Run experiments** access can also send telemetry in the `experiment` environment, because the SDKs record each run of an experiment item there. Read [The environment and the key](/evals/experiments#the-environment-and-the-key). + ## Revoke a key Select **Revoke** in the key's row, then select **Revoke key** to confirm. diff --git a/docs/platform/environments.mdx b/docs/platform/environments.mdx index d725811..fdfc94d 100644 --- a/docs/platform/environments.mdx +++ b/docs/platform/environments.mdx @@ -1,7 +1,7 @@ --- title: Environments description: Label telemetry by deployment, then filter by it, limit API keys to it, and set capture for it. -lastModified: 2026-10-28 +lastModified: 2026-10-30 --- An environment names the deployment that sent telemetry, such as `production`, `staging`, or `development`. Use environments to keep one project's deployments apart: you can filter by environment, limit an API key to one environment, and turn off prompt and response capture for one environment. @@ -25,11 +25,18 @@ Set the same environment name on every service in a deployment. The dashboard sh | Where | What you can do | | --- | --- | | **Traces** | Filter traces and spans by environment. The filter lists up to 100 environment names. The **Environment** column is hidden by default; turn it on in **Columns**. | +| **Sessions** | Filter sessions by environment. | | Trace detail | Read the trace's environment on the **Metadata** tab. | | **Logs** | Read a log's environment in the log details. | | **API keys** | Limit a key to one environment. | | **Settings** → **Privacy** | Turn prompt and response capture on or off for each environment. | +## The `experiment` environment + +A prompt experiment records each item run as a trace in the `experiment` environment. Set this environment in the SDK client before you run an experiment of your code. Read [The experiment environment](/evals#the-experiment-environment). + +The **Overview**, **Traces**, and **Sessions** pages leave out `experiment` by default. To see these traces, select `experiment` in the **Environment** filter of **Traces** or **Sessions**. Live evaluators with **Any environment** also leave it out. + ## Limit an API key to one environment Enter an **Environment** when you create a key. The key then accepts only telemetry with that environment and rejects other requests with `403 environment_mismatch`. Read [Limit a key to one environment](/platform/api-keys#limit-a-key-to-one-environment). diff --git a/docs/platform/privacy.mdx b/docs/platform/privacy.mdx index b5d615c..375a0dd 100644 --- a/docs/platform/privacy.mdx +++ b/docs/platform/privacy.mdx @@ -1,7 +1,7 @@ --- title: Privacy and retention description: Choose what telemetry.dev stores, what it redacts, and how long it keeps telemetry. -lastModified: 2026-10-27 +lastModified: 2026-10-30 --- telemetry.dev stores prompts and responses by default. You can limit what it keeps in three places: @@ -51,7 +51,7 @@ A workspace owner or admin can change capture settings. Members can view them. E Under **Prompt capture**, the `production` and `development` rows are always present. For another environment, select **Add environment**, enter its **Name**, and select **Add environment**. - Turn off the switch in the environment's row. The row then says "Prompts and responses are not stored." + Turn off the switch in the environment's row. The row then says "Prompts and responses are not stored. Live evaluators that read them show Not scored." @@ -86,6 +86,19 @@ Capture-off finds content by its key or event name. It does not read text to dec Redaction still runs on these values. It catches only the patterns described below. If a field can contain private text, remove it in your application. +### Capture-off and Evals + +When capture is off for an environment, Evals cannot read the content of its traces: + +- A live evaluator that reads the input or the output gives **Not scored**. Read [Prompt capture off](/evals/evaluators#prompt-capture-off). +- telemetry.dev cannot copy the traces of the environment into a dataset, because it stored no input. + +Capture settings do not apply to the outputs that your code sends with `runExperiment` or `run_experiment`. telemetry.dev keeps them with the experiment. Read [Run your code](/evals/experiments#run-your-code). + +## Content that Evals sends to model providers + +An LLM judge sends its prompt to the model provider of the judge, with the project's provider key. On live and past traces, the prompt has the stored trace content that its variables hold, after redaction. In an experiment, the prompt has the dataset item and the output, and the outputs that your code sends get no redaction. A prompt experiment sends each dataset item to the model of the experiment. Code checks and rules run on telemetry.dev servers and send no content to a model provider. Read [What leaves telemetry.dev](/evals/evaluators#what-leaves-telemetrydev). + ## What built-in redaction removes Built-in redaction is always on. You cannot turn it off. @@ -172,4 +185,6 @@ A new project starts at **Data retention** under **Defaults for new projects** i Dashboard views show only telemetry inside the retention window, so a shorter retention hides older data right away. A cleanup job then deletes telemetry older than the project's retention. It runs about once a day. +Retention also deletes the scores of the traces that it deletes. Datasets and experiments do not follow retention. A dataset item that came from a trace is a copy, and it stays until you delete it or its dataset. An experiment keeps its outputs and scores until you delete it or its dataset. + The storage layer also deletes all telemetry after 90 days, whatever the project setting. diff --git a/docs/platform/traces.mdx b/docs/platform/traces.mdx index ce1b486..0b3c9f8 100644 --- a/docs/platform/traces.mdx +++ b/docs/platform/traces.mdx @@ -1,7 +1,7 @@ --- title: Traces, sessions, and logs description: Find a request, inspect its spans, follow a conversation, and read related logs. -lastModified: 2026-10-28 +lastModified: 2026-10-30 --- A trace is one request through your application. Each step inside it, such as a model call, a tool call, or an agent step, is a span. Use the trace explorer to find failed or slow requests and to see what each model call received and returned. @@ -16,7 +16,7 @@ Both lists have these filters: | --- | --- | | Search | Matches trace names or span names. It does not search prompt or response content. | | Status | Shows **All statuses**, `success`, or `error`. | -| Environment | Lists up to 100 environment names from your telemetry. Names match regardless of case and surrounding spaces, so `production` also shows telemetry sent as `Production`. | +| Environment | Lists up to 100 environment names from your telemetry. Names match regardless of case and surrounding spaces, so `production` also shows telemetry sent as `Production`. Without a selection, the lists leave out the `experiment` environment of [experiment runs](/evals/experiments). | | Framework | Lists the frameworks detected in your telemetry. | | Date range | Shows **Last 7 days**, **Last 30 days**, or **Last 90 days**. The default is 30 days. | | Session | Select a value in the **Session** column. A chip shows the filter; select it to clear the filter. | @@ -30,7 +30,9 @@ The table shows one page at a time. Use the pager below it to move between pages ### Trace columns -The trace list shows **Date** and **Trace**, plus these columns: **Input**, **Output**, **Duration**, **Tokens**, **Cost**, **Spans**, **Models**, **Session**, **User**, and **Environment**. +The trace list shows **Date** and **Trace**, plus these columns: **Scores**, **Prompt**, **Input**, **Output**, **Duration**, **Tokens**, **Cost**, **Spans**, **Models**, **Session**, **User**, and **Environment**. + +- **Scores** shows one [score](/evals/scores) of the trace with its value, and **+N** for the others. Select a value to filter the list by it. - **Input** and **Output** show the start of the request's prompt and reply. - **Duration** shows the time to first token when you hover over it, if the trace has that value. @@ -47,9 +49,13 @@ Select a span row to open its trace with that span selected. Select **Columns** to show or hide columns. **Environment** is hidden by default in both lists, and **Service** is hidden by default in the span list. Your browser keeps the choice for later visits. +### Select traces + +In the trace list, select the check boxes of rows, then select **Add to dataset** or **Add to review queue**. You can select the rows of one page. A change of the filters or the page clears the selection. Read [Add traces and sessions](/evals/datasets#add-traces-and-sessions) and [Add traces by hand](/evals/review-queues#add-traces-by-hand). + ## Inspect a trace -Select a trace row to open the trace. The header shows the trace's name, its status, and its ID, with a button to copy the ID. Below the header are two tabs: +Select a trace row to open the trace. The header shows the trace's name, its status, and its ID, with a button to copy the ID. The header also has **Add to dataset** and **Add to review queue**. Below the header are two tabs: - **Trace**: the span tree, with a bar for each span on a shared time axis, nested under its parent. - **Metadata**: the trace's details. **Trace** lists the **Trace ID**, **Started**, **Duration**, **Turns**, **Spans**, and **Errors**. **Usage** lists the **Models**, the token counts, and the **Cost**. **Source** lists the **Agent**, **Service**, **Environment**, **Framework**, **Session**, and **User**. The trace's metadata follows, if it has any. @@ -74,6 +80,7 @@ Select a span to open its panel. The panel header shows the span's type and name - **Error**: the error message and details, for a failed span. - **Metrics**: when the span started, its duration, and its offset from the start of the trace. Model calls also show **First token**, **Output speed**, **Cost**, and their tokens. +- **Scores**: the scores of the trace and the span, with the source and the reason of each. The root span always shows this section, with **Add score**. Read [Read scores on a trace](/evals/scores#read-scores-on-a-trace). - A section for the kind of span, such as **Model call** with the **Requested model**, **Response model**, **Provider**, **Finish reason**, and **Response ID**, or **Tool call**, **Agent**, or **MCP**. - **Input** and **Output**: the prompt and the reply. In **Output**, a model's reasoning, such as Anthropic thinking or Gemini thoughts, appears as **Reasoning** above the reply when it was captured. A tool call shows **Arguments** and **Result** instead. Where a section offers them, select **Pretty** for a formatted view or **JSON** for the stored value. - **Events**: the span events and their attributes. @@ -87,9 +94,9 @@ If prompt and response capture is off for the environment, the **Input** and **O Select **Sessions** in the project sidebar to list conversations. A session groups the traces that share a session ID. To set one, read [Add user, session, and metadata](/sdk/typescript#add-user-session-and-metadata) for TypeScript or [Python](/sdk/python#add-user-session-and-metadata). -Select **24h**, **3d**, **7d**, or **30d** to set the time range. You can search by session ID or trace name and filter by agent, user, or model. The list shows each session's **Agent**, **Model**, **Customer**, **Turns**, **Tokens**, **Cost**, and **Last active** time. +Select **24h**, **3d**, **7d**, or **30d** to set the time range. You can search by session ID or trace name and filter by agent, user, model, or environment. The list shows each session's **Agent**, **Model**, **Customer**, **Turns**, **Tokens**, **Cost**, and **Last active** time. -Select a session to see its **Customer**, **Agent**, **Models**, **Started** time, **Duration**, **Tokens**, and **Cost**, a list of its **Turns**, and each turn of the conversation. Select **Open in Traces** to list the session's traces, or **Open trace** if the session has one trace. +Select a session to see its **Customer**, **Agent**, **Models**, **Started** time, **Duration**, **Tokens**, and **Cost**, a list of its **Turns**, and each turn of the conversation. Select **Open in Traces** to list the session's traces, or **Open trace** if the session has one trace. Select **Add to dataset** or **Add to review queue** to send the session to Evals. The session page also shows the [scores](/evals/scores#read-scores-on-a-session) of the session and of each turn. ## Read logs diff --git a/docs/reference/evals-api.mdx b/docs/reference/evals-api.mdx new file mode 100644 index 0000000..7e51b72 --- /dev/null +++ b/docs/reference/evals-api.mdx @@ -0,0 +1,188 @@ +--- +title: Evals API +description: Read dataset items, run experiments of your code, and send scores over HTTP, with request fields, limits, and error codes. +lastModified: 2026-10-30 +--- + +The Evals API lets your code read the items of a dataset, send the outputs of an experiment, and send scores over HTTP. The TypeScript and Python SDKs use this API in `runExperiment` and `score`. Read [Experiments](/evals/experiments) and [Scores](/evals/scores) first. + +The API is at `https://api.telemetry.dev`, the same host as the [OTLP ingest API](/reference/otlp). `https://ingest.telemetry.dev` also works. The [OpenAPI document](https://telemetry.dev/openapi.json) describes each route. + +## Endpoints + +| Method | Path | Purpose | Scope | +| --- | --- | --- | --- | +| `GET` | `/v1/datasets/{name}` | Get a page of the items of a dataset version | `datasets:read` | +| `POST` | `/v1/experiments` | Start an experiment of your code | `experiments:write` | +| `POST` | `/v1/experiments/{id}/items` | Send the runs of items | `experiments:write` | +| `POST` | `/v1/experiments/{id}/complete` | Tell telemetry.dev that you sent all runs | `experiments:write` | +| `GET` | `/v1/experiments/{id}` | Get the status and the scores of an experiment | `experiments:write` | +| `POST` | `/v1/scores` | Record a score on a trace, a span, or a session | `scores:write` | + +## Authentication + +Send a project API key as a bearer token: + +```http +Authorization: Bearer td_live_your_key +``` + +The **Run experiments** access of a key gives the three scopes `datasets:read`, `experiments:write`, and `scores:write`. Read [Select the access of a key](/platform/api-keys#select-the-access-of-a-key). A key without the scope of a route gets `403 insufficient_scope`. + +The key also selects the project. Dataset names and experiment IDs are those of the project of the key. + +## Get a dataset + +```sh +curl "https://api.telemetry.dev/v1/datasets/support-golden?limit=100" \ + -H "Authorization: Bearer $TELEMETRY_DEV_API_KEY" +``` + +| Query parameter | Description | +| --- | --- | +| `version` | The dataset version. Without it, the API reads the newest version. | +| `split` | Get only the items of this split. 1 to 64 characters. | +| `limit` | Items in a page, 1 to 100. The default is 100. | +| `cursor` | The `nextCursor` of the page before. | + +```json +{ + "dataset": { "id": "…", "name": "support-golden", "version": 3 }, + "items": [ + { + "id": "…", + "number": 1, + "input": { "question": "Where is my refund?" }, + "expectedOutput": "Refunds take 5 to 7 days.", + "metadata": {}, + "tags": ["refunds"], + "split": "test" + } + ], + "nextCursor": "…" +} +``` + +- Items come in number order. The `id` of an item is the same in each version. Send it as `itemId` with the run of the item. +- A page ends before `limit` when its items have 4 MiB of JSON. This cut always leaves at least one item in the page. +- The cursor holds the version. Thus each page reads the same version, also when the dataset changes. `nextCursor` is `null` on the last page. +- A dataset before its first change is at version 0, with no items. + +## Run an experiment + +An experiment of your code has three steps: + +1. Start the experiment with `POST /v1/experiments`. +2. Run your code on each item, and send the runs with `POST /v1/experiments/{id}/items`. +3. Send `POST /v1/experiments/{id}/complete`. Then read the result with `GET /v1/experiments/{id}`. + +### Start the experiment + +`POST /v1/experiments` takes a JSON body of up to 1 MiB: + +| Field | Description | +| --- | --- | +| `dataset` | Necessary. The dataset name, such as `support-golden`. | +| `name` | Up to 128 characters. The default is `-v`. If the project has the name, telemetry.dev adds `-2`, `-3`, and so on. | +| `datasetVersion` | The version to run. The default is the newest version. | +| `split` | Run only the items of this split. | +| `runsPerItem` | 1 to 5. The default is 1. | +| `evaluators` | Up to 20 names of LLM judges, code checks, and rules of the project. telemetry.dev scores each run with them. | +| `minScores` | Up to 20 pass marks by score name: the lowest pass rate (0 to 1) of a pass or fail score, or the lowest mean of a number score. | +| `ci` | The GitHub Actions run: `provider` (`github_actions`), `repository` (`owner/name`), `commit`, and the optional `runUrl`, `prNumber`, `prTitle`, and `prUrl`. | +| `metadata` | Up to 16 KiB of JSON. telemetry.dev applies the redaction of the project to its strings. | + +The response is `201` with the `id`, the `name`, the `datasetVersion`, the `itemsTotal` (the items multiplied by the runs for each item), and the `url` of the experiment page. The experiment is `running` immediately. + +This request makes a new experiment each time. Send it again only after a `429`. + +### Send the runs + +`POST /v1/experiments/{id}/items` takes 1 to 100 runs in `items`, in a body of up to 16 MiB: + +| Field | Description | +| --- | --- | +| `itemId` | Necessary. The `id` of the item from `GET /v1/datasets/{name}`. | +| `runIndex` | 0 to `runsPerItem` − 1. The default is 0. | +| `output` | The output of your code, up to 100,000 characters. | +| `traceId` | The trace of the run, as 32 lowercase hex characters. If the run has no `costUsd`, telemetry.dev reads the cost of the run from this trace. | +| `latencyMs` | The duration of the run in milliseconds. | +| `costUsd` | The cost of the run, 0 to 999,999. | +| `error` | The error of a run that was not successful. telemetry.dev keeps the first 4,000 characters, after redaction. | +| `scores` | Up to 20 scores from your code, each with a `name`, a `value` or a `label`, and an optional `reason`. Each name one time only. | + +The response is `200` with `accepted` and `duplicates`. A run that the experiment has, by `itemId` and `runIndex`, keeps its first post. Thus you can send a request again after a timeout. The request adds all of its runs or none. + +### Complete and read the result + +`POST /v1/experiments/{id}/complete` answers `200` with the `id` and the `status`. The status stays `running` until telemetry.dev scores the last runs. Then the experiment completes, and telemetry.dev does a check of the pass marks. + +`GET /v1/experiments/{id}` returns these fields: + +| Field | Description | +| --- | --- | +| `status` | `queued`, `running`, `completed`, `failed`, or `stopped`. | +| `checkStatus` | `passed`, `failed`, or `null` when the experiment has no pass marks or did not complete. | +| `itemsTotal`, `itemsDone`, `itemsFailed` | The counts of runs. | +| `error` | Why the experiment failed. | +| `scores` | For each score name: `kind`, `value` (a pass rate from 0 to 1, or a mean), `passCount`, `failCount`, `baselineValue`, `delta`, `minScore`, and `passed`. | +| `url` | The experiment page. | + +The `delta` is in whole points for a pass rate, and in one decimal for a mean. An experiment that gets no runs for 24 hours ends with the runs that it has. + +## Send a score + +```sh +curl https://api.telemetry.dev/v1/scores \ + -H "Authorization: Bearer $TELEMETRY_DEV_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"name":"user_feedback","traceId":"4bf92f3577b34da6a3ce929d0e0e4736","value":0,"comment":"Wrong amount"}' +``` + +| Field | Description | +| --- | --- | +| `name` | Necessary. The score name, 1 to 64 characters. | +| `traceId` | 32 lowercase hex characters, not all zeros. | +| `spanId` | 16 lowercase hex characters. Give it with `traceId` to score one span. | +| `sessionId` | 1 to 1,024 characters. | +| `value` | A number. | +| `label` | A label, such as `pass`, `fail`, or a label of your own. | +| `comment` | Up to 4,000 characters. | + +Give `traceId`, `sessionId`, or the two. Give `value`, `label`, or the two. The label `pass` goes with the value 1, and `fail` with 0. A `pass` or `fail` label without a value gets 1 or 0. `user_feedback` takes the value 1 for up or 0 for down, and no label. + +The body can have up to 64 KiB. The response is `202` with the `id` of the score. telemetry.dev applies the redaction of the project to the comment. If the redaction would change the session ID, telemetry.dev drops the session ID. A score without a `traceId` then gets `400`. Each request adds a new score, also for the same name and trace. + +## Errors + +An error has a JSON body with a code and a message: + +```json +{ "error": { "code": "insufficient_scope", "message": "This API key cannot send scores. Create a key with Run experiments access." } } +``` + +| HTTP | Code | Cause | +| --- | --- | --- | +| `400` | `invalid_request` | The body or a parameter is not valid. The message names the problem. | +| `400` | `decompression_failed` | The gzip body does not decompress. | +| `401` | `invalid_api_key` | The key is missing, malformed, unknown, or revoked. | +| `403` | `insufficient_scope` | The key does not have the scope of the route. | +| `403` | `project_not_accepting_telemetry` | **Accept telemetry** is off for the project. This applies to `POST /v1/experiments`, `POST /v1/experiments/{id}/items`, and `POST /v1/scores`. | +| `404` | `dataset_not_found` | The project has no dataset of that name. | +| `404` | `version_not_found` | The dataset has no such version. | +| `404` | `experiment_not_found` | The project has no experiment with that ID. | +| `409` | `experiment_ended` | The experiment ended and takes no more runs. | +| `409` | `experiment_not_code` | The experiment runs a prompt version. Only experiments of your code take runs. | +| `409` | `experiment_name_taken` | The name is in use, and telemetry.dev could not add a free number to it. Give a different name. | +| `413` | `body_too_large` | The body is larger than the limit of the route. | +| `415` | `unsupported_encoding` | The `Content-Encoding` is not `gzip` or `identity`. | +| `422` | `dataset_empty` | The dataset version, or its split, has no items. | +| `422` | `evaluator_not_found` | The project has no evaluator of that name. | +| `422` | `evaluator_not_supported` | The evaluator is not an LLM judge, a code check, or a rule. Experiments run only these types. | +| `422` | `item_not_found` | The dataset version has no item with that `itemId`. | +| `429` | `rate_limited` | Too many requests for the project, or too many failed authentications. Wait for `Retry-After`. | +| `500` | `internal_error` | The server could not answer. | +| `500` | `privacy_configuration_invalid` | telemetry.dev cannot read the privacy settings of the project. | +| `503` | `evals_unavailable` | Evals is not available at this time. Send the request again later. | + +The Evals routes have their own limit of 6,000 requests for each project in a minute. This limit is separate from the limit of the OTLP routes. Read [Rate limits and quotas](/reference/otlp#rate-limits-and-quotas). diff --git a/docs/reference/meta.ts b/docs/reference/meta.ts index 834cc19..dff4948 100644 --- a/docs/reference/meta.ts +++ b/docs/reference/meta.ts @@ -3,6 +3,6 @@ import { defineMeta } from "blume"; export default defineMeta({ title: "Reference", icon: "book-open", - order: 6, - pages: ["otlp", "span-attributes", "cost"], + order: 7, + pages: ["otlp", "evals-api", "span-attributes", "cost"], }); diff --git a/docs/sdk/python.mdx b/docs/sdk/python.mdx index 0022779..2f83273 100644 --- a/docs/sdk/python.mdx +++ b/docs/sdk/python.mdx @@ -1,7 +1,7 @@ --- title: Python SDK description: Add spans, logs, metrics, and trace context to Python applications. -lastModified: 2026-10-26 +lastModified: 2026-10-30 seo: title: "Python SDK for LLM Tracing" description: "Install telemetry-dev to add OpenTelemetry traces, logs, metrics, and trace context to Python AI applications. The SDK sends data to telemetry.dev over OTLP." @@ -491,6 +491,15 @@ with start_span("chat-stream", type="generation", model="gpt-4o") as span: After the first chunk, each interval between chunks feeds the `time_per_output_chunk` histogram. The SDK times chunks when your loop receives them, so time your code spends between reads counts toward the interval. `record_output_chunk()` uses `time.perf_counter()` by default. If you pass your own `timestamp_ms`, use the same monotonic millisecond clock for every chunk of the span. +## Run experiments and send scores + +`telemetry-dev` 0.3.2 and later has these functions for [Evals](/evals): + +- `run_experiment(...)` runs your code on each item of a dataset, and records the outputs and the scores as an experiment. `run_experiment_async(...)` takes `async` tasks and scorers. Read [Run your code](/evals/experiments#run-your-code). +- `score(...)` records a score on a trace, a span, or a session, such as the thumbs up or down of a user. `score_async(...)` sends it from a worker thread. Read [Send scores from your app](/evals/scores#send-scores-from-your-app). + +The functions use the API key and the base URL of the enabled client. Without a client, they use `TELEMETRY_DEV_API_KEY` and `TELEMETRY_DEV_BASE_URL`. Each function also takes its own `api_key` and `base_url` arguments. The key must have **Run experiments** access. `run_experiment` also sends the traces of the items, so the key of the client must also have **Send telemetry**. Read [Select the access of a key](/platform/api-keys#select-the-access-of-a-key). + ## Flush and shut down `flush(timeout_s=10.0)` sends pending traces, logs, and metrics. `shutdown(timeout_s=10.0)` sends pending data, releases resources, and clears the active client. Calling either one again is safe. diff --git a/docs/sdk/typescript.mdx b/docs/sdk/typescript.mdx index 94d7ffb..f2c5c16 100644 --- a/docs/sdk/typescript.mdx +++ b/docs/sdk/typescript.mdx @@ -1,7 +1,7 @@ --- title: TypeScript SDK description: Add spans, logs, metrics, and trace context to TypeScript applications. -lastModified: 2026-10-26 +lastModified: 2026-10-30 seo: title: "TypeScript SDK for LLM Tracing" description: "Install @telemetry-dev/sdk to add OpenTelemetry spans, logs, metrics, and trace context to TypeScript AI applications and send them to telemetry.dev over OTLP." @@ -495,6 +495,15 @@ span.end({ finishReason: "stop" }); After the first chunk, each interval between chunks feeds the `time_per_output_chunk` histogram. The SDK times chunks when your loop receives them, so time your code spends between reads counts toward the interval. `recordOutputChunk()` uses `performance.now()` by default. If you pass your own timestamp, use the same clock for every chunk of the span. +## Run experiments and send scores + +`@telemetry-dev/sdk` 0.2.2 and later has two functions for [Evals](/evals): + +- `runExperiment(options)` runs your code on each item of a dataset, and records the outputs and the scores as an experiment. Read [Run your code](/evals/experiments#run-your-code). +- `score(options)` records a score on a trace, a span, or a session, such as the thumbs up or down of a user. Read [Send scores from your app](/evals/scores#send-scores-from-your-app). + +The two functions use the API key and the base URL of the initialized client. Without a client, they use `TELEMETRY_DEV_API_KEY` and `TELEMETRY_DEV_BASE_URL`. Each function also takes its own `apiKey`, `baseUrl`, and `fetch` options. The key must have **Run experiments** access. `runExperiment` also sends the traces of the items, so the key of the client must also have **Send telemetry**. Read [Select the access of a key](/platform/api-keys#select-the-access-of-a-key). + ## Flush and shut down `flush()` sends pending traces, logs, and metrics. `shutdown()` sends pending data, releases resources, and turns the client off. Calling either one again is safe.