ChainOfThought, ReAct, and custom Module classes that can be optimized and compiled.
HoneyHive integrates with DSPy via the OpenInference DSPy instrumentor, which captures module calls, LM interactions, and tool executions as OpenTelemetry spans.
Quick Start
Last tested with
dspy 3.1.x (April 2026). Requires DSPy 3.x; the API changed significantly from 2.x.What Gets Traced
The instrumentation automatically captures:- Module calls — Every
forward()invocation with inputs and outputs (ReAct, ChainOfThought, Predict, custom Modules) - LLM calls — Model requests, responses, and token usage via the OpenAI instrumentor
- Tool executions — Each tool call with arguments and results (in ReAct agents)
- Pipeline composition — Parent-child nesting when Modules call sub-Modules
Example: ReAct Agent with Tools
Example: Multi-Module Pipeline
DSPy’sModule class lets you compose sub-modules into pipelines. Each module call is traced as a separate span with correct parent-child nesting:
Example: Custom Business Logic with @trace
Use the @trace decorator to wrap business logic that orchestrates multiple DSPy module calls. This creates a parent span encompassing the entire workflow, with DSPy module calls as child spans:
@trace decorator and enrich_span() give you:
- A parent span for the full business workflow
- Custom metadata (order ID, priority, category) attached to the span
- Custom metrics (steps completed) for monitoring
- DSPy module calls automatically nested as child spans
Troubleshooting
Traces not appearing
- Call
.instrument()before running any DSPy code — Instrumentation must be active before module execution:
-
Check environment variables — Ensure
HH_API_KEYis set - Add the OpenAI instrumentor — DSPy uses LiteLLM/OpenAI under the hood. Adding the OpenAI instrumentor captures detailed LLM-level spans:
- Clean up instrumentors on exit — Call
.uninstrument()to avoid duplicate spans in long-running processes:
Related
Enrich Your Traces
Add user IDs and custom metadata to DSPy traces
Custom Spans
Create spans for business logic around module calls
Distributed Tracing
Trace pipelines across service boundaries
Query Trace Data
Export traces programmatically

