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}")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traceai_dspy-0.1.4.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traceai_dspy-0.1.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file traceai_dspy-0.1.4.tar.gz.

File metadata

  • Download URL: traceai_dspy-0.1.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_dspy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f80e0c663cf5615f7b6125329478577a5ff42e6fa688b8f007c5b6f8e002c220
MD5 d54a0cb5f94f9296ed7b57de8fec5692
BLAKE2b-256 402f0f8280789521e69a8042966aadbf646fb6ebd8bcac32b541992e8ac25309

See more details on using hashes here.

File details

Details for the file traceai_dspy-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: traceai_dspy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_dspy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 df44c88ad2d11c48bcbaac05058e79223b1126cf7691524357c9067805cf85fd
MD5 e9fcadca43f63230df4c607c95115c9b
BLAKE2b-256 313dfc45302d961f7a5c9e9ed6c28d3c2d248533fec6b6f19ccd6ea28e10d28c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

3 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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