Explore: Search and inspect production traces
On this page
Lesson rewritten November 2, 2026 based on Mistral’s Send traces and Explore traces pages and the
mistralaiSDK 3.7.0: The Explorer focuses on OpenTelemetry traces queried via a search expression language; the legacychat_completion_events.searchmethod no longer exists. Sources: Send traces · Explore traces.
The Explorer: Your window into production
The Trace Explorer is where you search, filter, and inspect every trace flowing through your AI applications. You’ll find it in Studio under Observability → Traces. However, traces won’t appear there unless you enable them first: tracing is disabled by default.
Sending traces
With the Python SDK, install the telemetry extension (mistralai[telemetry], version 2.4.13 or later), then enable it on the client:
from mistralai.client import Mistral
from mistralai.extra.observability import configure_telemetry
client = Mistral(api_key="your-api-key")
configure_telemetry(client)
From that point on, the SDK automatically traces model calls, embeddings, agent operations, FIM completions, and OCR. Calls to your own tools aren’t traced out of the box: you must add their spans using the SDK’s tracer.
from mistralai.extra.observability import get_telemetry_tracer
tracer = get_telemetry_tracer(client, "agent-support")
with tracer.start_as_current_span("invoke_agent"):
response = client.chat.complete(
model="mistral-small-latest",
messages=[{"role": "user", "content": "What is the status of order 4521?"}],
)
with tracer.start_as_current_span("execute_tool order_tracking") as span_tool:
span_tool.set_attribute("gen_ai.tool.name", "order_tracking")
span_tool.set_attribute("gen_ai.tool.call.arguments", "4521")
# call your tool here
Other sources behave differently: Workflows trace every execution as soon as OTEL_ENABLED=true is set on the service, while Vibe Work activates via an admin setting in Studio. The TypeScript SDK offers configureTelemetry. Conversely, Vibe Code (CLI and Web) and the Studio Playground do not send traces. All sources redact part of the data by default before export; the Data redaction page details this policy and how to adjust it.
What a trace contains
A trace is a tree of spans, where each span represents an operation in the chain:
| Field | Content |
|---|---|
| Trace ID | Identifier for the entire execution chain |
| Spans | Operations: model calls, tool calls, workflow steps |
| Duration | Time for each span and the entire trace |
| Tokens | Input and output tokens for each model call |
| Status | Success or error, including the error message |
| Source | Origin product: SDK, Workflows, Vibe Work |
| Tags | Labels applied by the SDK and automatic metadata, such as the model |
Clicking a trace opens its span tree; each span expands to show input, output, latency, and tokens.
The search language
The Explorer accepts an expression language: conditions on trace fields combined with AND, OR, and NOT.
| Category | Operators | Example |
|---|---|---|
| Comparison | =, !=, <, <=, >, >= | duration_ns > 5000000000 |
| Pattern | LIKE, ILIKE, NOT LIKE | service_name LIKE '%agent%' |
| Substring | CONTAINS, NOT CONTAINS | service_name CONTAINS 'sdk' |
| Regular expression | REGEXP, NOT REGEXP | service_name REGEXP '^my-' |
| Range | BETWEEN ... AND ... | duration_ns BETWEEN 1000000 AND 5000000000 |
| List | IN (...), NOT IN (...) | status_code IN ('Error', 'Ok') |
| Presence | EXISTS, NOT EXISTS | error_message EXISTS |
Available fields include service_name, status_code (Ok or Error), duration_ns (in nanoseconds), error_message, start_time, models_used (a list), and any span attribute using bracket syntax: span_attributes['gen_ai.request.model']. For lists, has(models_used, 'mistral-medium-latest'), hasany(...), and hasall(...) complement CONTAINS.
# All failed traces from a service
service_name = 'agent-support' AND status_code = 'Error'
# Traces longer than 5 seconds
duration_ns > 5000000000
# Traces that called a specific model
span_attributes['gen_ai.request.model'] CONTAINS 'mistral-large'
If a search returns no results, remove all conditions except the time range, then re-add them one by one. A common mistake is filtering for status_code = 'Error' when most traces succeed.
Querying traces via the SDK
You can perform the same searches programmatically over a time range:
from datetime import datetime, timedelta, timezone
from mistralai.client import Mistral
client = Mistral(api_key="your-api-key")
now = datetime.now(timezone.utc)
response = client.beta.observability.traces.search(
from_=now - timedelta(days=1),
to=now,
search_expression="service_name = 'agent-support' AND status_code = 'Error'",
page_size=50,
)
for trace in response.traces.results or []:
print(f"{trace.trace_id} {trace.root_span_name} : {trace.duration_ns / 1e9:.1f} s")
The response uses cursor-based pagination. The API reference documents the Traces and Spans endpoints (search, single trace, possible fields and values, spans of a trace).
Adding spans to a dataset
The Explorer also serves as a starting point for test datasets. From a trace, a span’s menu offers Add span to dataset; in Spans view, you can select up to 500 at once and map each span field to a record field. This function relates to offline evaluations, reserved for Enterprise organizations (Lesson 15).
Key takeaways
- Tracing is disabled by default:
configure_telemetry(client)enables it for the Python SDK,OTEL_ENABLED=truefor Workflows - Model calls are traced automatically; tool calls require manual tracing with
get_telemetry_tracer - The Explorer filters traces using an expression language (
service_name,status_code,duration_ns,span_attributes['…']) - The SDK exposes the same search capability:
client.beta.observability.traces.search(search_expression=...) - Interesting spans become dataset records in a single click or in batches of 500