Mirascope (tracing)
Mirascope (tracing)
Mirascope is a Python toolkit for building LLM applications with a unified model API, structured outputs, streaming, and typed tools. respan-instrumentation-mirascope traces Mirascope 2.x model operations as canonical Respan chat spans and toolkit execution as tool spans.
Synchronous and asynchronous calls are supported. Streaming spans stay open until the underlying stream is consumed, so their timing, output, usage, and iterator errors describe the complete stream.
Set up Respan
Create an account at platform.respan.ai and grab an API key.
Run npx @respan/cli setup to set up with your coding agent.
Example projects
Setup
Set environment variables
Use the credential required by your selected Mirascope provider when it is not OpenAI.
View your trace
Open the Traces page to inspect the Mirascope chat span, provider, model, messages, usage, and status.
Supported operations
Model calls include prompts, completions, tool definitions and calls, model and provider identifiers, and token usage when the provider response supplies them. Errors are re-raised unchanged after the span records OpenTelemetry error status, status_code, and error.message.
Stream model output
The stream span finishes when text_stream() is exhausted:
For an asynchronous stream, await stream_async() and consume its text stream with async for:
Trace tool execution
Tools passed to a model call are captured on the chat span. When Mirascope executes a returned tool call, the execution becomes a child tool span.
Configuration
Disable content capture
With capture disabled, messages, tool definitions, arguments, and model outputs are omitted. Provider, model, usage, timing, status, and exception type remain available.
Add trace context
Do not combine this adapter with mirascope.ops.instrument_llm() unless you intentionally want two independent telemetry pipelines for each operation.