DSPy Tracing in Phoenix
Published on . Updated on
I pop the following instrument_dspy()
into my utils
library to get tracing in Phoenix from DSPy.
![](https://nattaylor.com/wp-content/uploads/2024/05/arize-phoenix-1024x477.png)
def instrument_dspy():
"""Setup DSPy tracing in phoenix"""
import phoenix
import opentelemetry
import openinference.instrumentation.dspy
phoenix.launch_app()
opentelemetry.trace.set_tracer_provider(opentelemetry.sdk.trace.TracerProvider(
resource=opentelemetry.sdk.resources.Resource(attributes={}),
active_span_processor=opentelemetry.sdk.trace.export.SimpleSpanProcessor(
span_exporter=opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter(
endpoint=f'{phoenix.active_session().url}v1/traces'))))
openinference.instrumentation.dspy.DSPyInstrumentor().instrument()