DSPy is a framework for algorithmically optimizing LM prompts and weights, especially when LMs are used one or more times within a pipeline.

Langtrace has first class support for DSPy, allowing you to capture traces from your DSPy pipelines or agents automatically and analyze them in Langtrace.

Setup

  1. Follow the DSPy installation guide to install DSPy.
  2. Install Langtrace’s SDK and initialize the SDK in your code.
  3. Run your DSPy pipeline or agent and view the traces in Langtrace.

Traces

traces

Logs

traces

Troubleshooting

Missing LLM Calls in Traces

If you’re not seeing LLM calls in your Langtrace traces when using DSPy, consider the following:

Grouping of Spans in Trace when using ThreadpoolExecutor in DSPy

If you’re using ThreadpoolExecutor in DSPy to parallelize your modules, you may notice that the spans in the trace are not grouped together. This is because the spans are created in the same thread and are not propagated to the parent span. To resolve this issue,