Hi! We are evaluating phoenix arize for observing a new dspy application using the DSPy instrumentation. This looks great, but one thing we haven't been able to figure out is how to pass metadata values into phoenix arize when using dspy. Has anyone done this? We're trying to use metadata to slice by session, user, customer, etc.
Hey Geert-Jan V. ! Metadata is relatively new but we do have semantic conventions for it! Since you Cannot I pass metadata into the DSPy program, you will have to wrap your DSPy invocation in a custom span. You鈥檒l then have to set the metadata you want to track as a JSON string. Here is a small guide on how to create custom spans. https://docs.arize.com/phoenix/tracing/how-to-tracing/custom-spans Let us know how it goes!
that works perfectly, thanks!
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!
oh Geert-Jan V. Great point! I forgot how flexible DSPy is! Very nice!
