> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update existing traces

> Learn how to update or delete traces previously published to the Openlayer platform

Sometimes the data you want to monitor isn’t available at inference time.
Openlayer lets you **update existing traces** after they were streamed to the platform.

Common use cases:

* Adding **ground truths** that only became available later.
* Logging **human feedback** (e.g., thumbs up/down, ratings).
* Attaching **business signals** such as conversions or revenue impact.

## How updates work

Every trace streamed to Openlayer has an **`inference_id`**, which is a unique identifier.

* If you provide your own inference IDs, you can easily reference and update those traces later.
* If you don’t, Openlayer auto-generates them for you.

<Tip>
  For maximum flexibility, set **custom inference IDs** when tracing. This makes
  it simple to tie traces to feedback, business outcomes, or other systems.
</Tip>

## Example: Add a ground truth

Let’s say you want to add a `ground_truth` column for a previously logged trace.

```python theme={null}
from openlayer import Openlayer
from openlayer.types.inference_pipelines import row_update_params

row_updates = {
    "ground_truth": "The sun is 94.471 million miles from the earth."
}

config = row_update_params.Config(
    ground_truth_column_name="ground_truth"
)

client = Openlayer()
client.inference_pipelines.rows.update(
    inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    inference_id="832y98d3",
    row=row_updates,
    config=config,
)
```

This updates the trace with `inference_id="832y98d3"` by attaching a ground truth.

### Using custom inference IDs

When tracing with the `@trace` decorator, you can set your own inference IDs.
This makes it easy to correlate requests with later feedback or business signals.

```python theme={null}
from openlayer.lib import trace, update_current_trace

@trace()
def process_chat_message(user_id: str, message: str, conversation_id: str):
    custom_id = f"chat_{conversation_id}_{user_id}"
    update_current_trace(inference_id=custom_id)

    response = generate_ai_response(message)

    # Store custom_id in your DB for later updates
    store_for_feedback(custom_id, user_id, message, response)

    return response
```

Later, use that custom ID (`chat_{conversation_id}_{user_id}`) in your update calls.

## Deleting production data

An update rewrites what a record says. **Deleting** removes the record entirely, which is what you
want when the data should not be in Openlayer at all: a load test skewing your metrics, or a trace
that captured something it shouldn't have.

Deleting records and sessions requires the `delete_monitoring_record` permission, which project
admins hold. See [Roles and permissions](/security/roles-and-permissions) for how permissions are
granted.

<Note>
  Deletion applies to the records Openlayer stores for you. When a project reads
  its data from an external table through a connector, such as
  [BigQuery](/integrations/bigquery), delete the rows in that table instead.
</Note>

### Delete a single record

Open the record from your project's data table and choose **Delete record**. Openlayer asks you to
confirm, and warns that the action cannot be undone and that the record leaves the data source
forever. Confirm with **Delete record**.

### Delete sessions

On **Sessions**, select the sessions you want to remove, then choose **Batch actions** → **Delete
selected**. The **Delete sessions** dialog states how many records go with them, along with their
scores, embeddings, and summaries. Type `I am sure` to confirm, then click **Delete sessions**, or
**Delete session** when you selected one.

Openlayer accepts up to **500 sessions per delete request**. Work through a larger cleanup in
batches.

### Delete a data source

Deleting a data source is wider than either action above. It removes the data source along with
everything attached to it, so reach for it only when you want the whole thing gone.

In your project, go to **Data sources**, then choose **Delete** from the row's overflow menu.
The **Delete data source** dialog names the data source and shows how many tests and records it
holds, with a **View** button so you can inspect it first. Confirm by typing the data source name,
which is what enables the **Delete data source** button, or **Cancel** to back out.

<Warning>
  Deleting a data source cannot be undone. Any test, monitoring data, insights,
  and more that belong to it are permanently lost.
</Warning>

This is an admin action, listed as **Delete inference pipelines** in the
[permission matrix](/security/roles-and-permissions#permission-matrix).

### What deletion removes

When you delete records or sessions, Openlayer registers the deletion immediately, so the data leaves
the UI right away, then purges the underlying records in the background: the traces and spans behind
each record, the test scores computed on them, embeddings, and OpenTelemetry spans.

<Warning>
  Deleting does not stop ingestion. If your application keeps streaming records
  under a `session_id` you deleted, the session comes back holding only the
  records that arrive afterwards. Stop sending that data first when you want it
  gone for good.
</Warning>

To script deletions instead of clicking through the UI, see
[Delete record](/api-reference/rest/monitoring/delete-inference) and
[Delete data source](/api-reference/rest/monitoring/delete-inference-pipeline) in the REST reference.
