Skip to main content

DSPy OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the DSPy framework. It enables tracing and monitoring of applications built with DSPy.

Installation

  1. Install traceAI DSPy
pip install traceAI-DSPy
  1. Install DSPy
pip install dspy

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="dspy_app"
)

Configure DSPy Instrumentation

Instrument the DSPy client to enable telemetry collection. This step ensures that all interactions with the DSPy SDK are tracked and monitored.

from traceai_dspy import DSPyInstrumentor

DSPyInstrumentor().instrument(tracer_provider=trace_provider)

Create DSPy Components

Set up your DSPy client with built-in observability.

import dspy

class BasicQA(dspy.Signature):
    """Answer questions with short factoid answers."""

    question = dspy.InputField()
    answer = dspy.OutputField(desc="often between 1 and 5 words")

if __name__ == "__main__":
    turbo = dspy.LM(model="openai/gpt-4")

    dspy.settings.configure(lm=turbo)

    # Define the predictor.
    generate_answer = dspy.Predict(BasicQA)

    # Call the predictor on a particular input.
    pred = generate_answer(question="What is the capital of the united states?")
    print(f"Predicted Answer: {pred.answer}")

Release files for traceAI-DSPy 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceAI-DSPy 0.1.8
File Size Uploaded
traceai_dspy-0.1.8.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-DSPy 0.1.8
File Interpreter ABI Platform
traceai_dspy-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / traceai_dspy-0.1.8.tar.gz

Download URL traceai_dspy-0.1.8.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fcc1d07a736fd68d640164f7f7f10207fd97768bd8359b8660a39248ffe49cf0
BLAKE2b-256 checksum
How to use checksums
16794c76b1dab2780413ed3f1207f0983076c1743fd2ca84e0d76b3ff05c518d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / traceai_dspy-0.1.8-py3-none-any.whl

Download URL traceai_dspy-0.1.8-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65dcf5ae0243c6745c115daa5244b04f6233fbbfdd24ede0381049db3971f81e
BLAKE2b-256 checksum
How to use checksums
d6eee3793a44e98e767042957babb1752c51c20ad7e8abcea8c878f07e038749
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

3 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page