Skip to main content
Available via: OpenTelemetry auto-instrumentation (Python). This is not a Zespan SDK wrapper — see Send traces from any OTel-instrumented app for how the underlying endpoint works.
OpenInference’s openinference-instrumentation-dspy package instruments DSPy’s module and predictor calls (Predict, ChainOfThought, ReAct, and DSPy’s own LM calls underneath) so every step of a DSPy pipeline — including compiled/optimized programs — shows up as a span, no changes to your DSPy code.

Installation

Setup

Use BatchSpanProcessor instead of SimpleSpanProcessor in production — the example above uses SimpleSpanProcessor (synchronous, one export per span) since it’s simpler for a first run, but it adds latency to every call at real traffic volume.

What gets captured

Each DSPy module invocation and its underlying LM call become spans in the same trace, so a compiled multi-step pipeline (retrieval, reasoning, self-refinement) shows up as one flame graph rather than disconnected calls. Fields map through the standard OpenTelemetry GenAI semantic conventions Zespan reads — model, tokens, prompts, and completions per step.