Hi! I have a Llama Index application where I'm gradually integrating DSPy modules. I'm using:
from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
from openinference.instrumentation.dspy import DSPyInstrumentor
from openinference.instrumentation.litellm import LiteLLMInstrumentor The calls I make to the DSPy module within the Llama Index workflow aren't nesting properly within the workflow traces — instead, they appear to escape into a separate scope. Anyone knows what might be causing this? Thanks!
This issue occurs because DSPy, LlamaIndex, and LiteLLM instrumentors each create their own spans, but context propagation between LlamaIndex and DSPy is not automatic—DSPy spans may not be parented to the active LlamaIndex workflow span, resulting in traces that are not properly nested. This is a known limitation and is not explicitly addressed in the current Phoenix or OpenInference documentation; there is no built-in mechanism to ensure DSPy spans are always children of LlamaIndex workflow spans when both are instrumented independently. You may need to manually manage context or use custom span management to achieve correct nesting, as automatic context propagation between these frameworks is not guaranteed by the instrumentors alone. See DSPy Tracing and LlamaIndex Tracing for details.Would you like more detail on possible workarounds or custom context management?Sources: - LlamaIndex Tracing
💡 Hint: Mention RunLLM in the thread for followups.
