DSPy Tracing in Phoenix
Published on .
I pop the following instrument_dspy()
into my utils
library to get tracing in Phoenix from DSPy.
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()
Code language: Python (python)