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.7.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.7-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_dspy-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 cea00b0500c20a7b809e4eac300860b6c4725767e3ed952ead5ad73f9990fa0a
MD5 1e374f69ba103842e45239e68a056b9d
BLAKE2b-256 67160a1f88055d3dd00e7034ebfb8c683fb6f32f818a8323b08d576e6a54a323

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_dspy-0.1.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f9148f4071dba8424a53bb7aac6db7fa4f8997988c43edaa7953d6f836b7a20e
MD5 7ad7d7a8cc390509710ccb23a3c51065
BLAKE2b-256 f107d850b3475afa98658692274d619f533b5d41b396f7310c15da037fde1ac6

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.8

2 files

This release

0.1.7 This release

2 files

0.1.6

2 files

0.1.5

3 files

0.1.4

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