It's added at the forward step
def forward(self, question):
current_span = trace_api.get_current_span()
print(current_span.get_span_context().span_id)
context = self.retrieve(question).passages
prediction = self.generate_answer(context=context, question=question)
return dspy.Prediction(context=context, answer=prediction.answer, span_id=current_span.get_span_context().span_id)
That's where data from the result comes back to the framework. Adding the span_id as part of the prediction is a bit of a hack. But you can just ignore it.