Skip to main content
Lesson 12 of 16 · Production: Batch, Optimization, and Observability

Explore: Search and inspect production traces

Lesson 12 of 16 Updated November 2, 2026 Advanced
On this page
  1. The Explorer: Your window into production
  2. Sending traces
  3. What a trace contains
  4. The search language
  5. Querying traces via the SDK
  6. Adding spans to a dataset
  7. Key takeaways

Lesson rewritten November 2, 2026 based on Mistral’s Send traces and Explore traces pages and the mistralai SDK 3.7.0: The Explorer focuses on OpenTelemetry traces queried via a search expression language; the legacy chat_completion_events.search method 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:

FieldContent
Trace IDIdentifier for the entire execution chain
SpansOperations: model calls, tool calls, workflow steps
DurationTime for each span and the entire trace
TokensInput and output tokens for each model call
StatusSuccess or error, including the error message
SourceOrigin product: SDK, Workflows, Vibe Work
TagsLabels 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.

CategoryOperatorsExample
Comparison=, !=, <, <=, >, >=duration_ns > 5000000000
PatternLIKE, ILIKE, NOT LIKEservice_name LIKE '%agent%'
SubstringCONTAINS, NOT CONTAINSservice_name CONTAINS 'sdk'
Regular expressionREGEXP, NOT REGEXPservice_name REGEXP '^my-'
RangeBETWEEN ... AND ...duration_ns BETWEEN 1000000 AND 5000000000
ListIN (...), NOT IN (...)status_code IN ('Error', 'Ok')
PresenceEXISTS, NOT EXISTSerror_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=true for 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