{"library":"openinference-instrumentation-dspy","title":"OpenInference DSPy Instrumentation","description":"OpenTelemetry instrumentation for DSPy that automatically traces LLM calls, retrievers, and chain-of-thought reasoning. Current version 0.1.34, requires Python >=3.10, <3.15. Part of the Arize OpenInference ecosystem, actively maintained.","language":"python","status":"active","last_verified":"Fri May 01","install":{"commands":["pip install openinference-instrumentation-dspy"],"cli":null},"imports":["from openinference.instrumentation.dspy import DSPyInstrumentor"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import SimpleSpanProcessor\nfrom openinference.instrumentation.dspy import DSPyInstrumentor\nfrom openinference.semconv.trace import SpanAttributes\n\n# Set up a tracer provider with a simple span processor (replace endpoint with your collector)\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\ntrace_provider = TracerProvider()\ntrace_provider.add_span_processor(\n    SimpleSpanProcessor(OTLPSpanExporter(endpoint=os.environ.get('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4318/v1/traces')))\n)\ntrace.set_tracer_provider(trace_provider)\n\n# Instrument DSPy\nDSPyInstrumentor().instrument()\n\n# Now use DSPy normally - all traces will be captured.\nimport dspy\nlm = dspy.LM('openai/gpt-4o-mini')\ndspy.configure(lm=lm)\ncoT = dspy.ChainOfThought('question -> answer')\nprint(coT(question=\"What is the capital of France?\"))","lang":"python","description":"Installs and configures the DSPy instrumentor, then runs a simple ChainOfThought example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}