Hi Mikyo for other people's reference, wrapping in a custom span in with ... block worked fine, but since dspy just executes python code i figured i would try setting attributes on the current span and that also works fine. If you have a dspy module, in the forward method you can just set any attributes with:
class QuestionClassifier(dspy.Module):
def __init__(self):
super().__init__()
[snip]
def forward(self, question: str) -> tuple[str,str]:
current_span = trace_api.get_current_span()
current_span.set_attribute("metadata", "{ 'foo': 'bar' }")
[your dspy code]
and this will show on the dspy module span
thanks Mikyo for pointing me in the right direction!