Skip to main content

OpenTelemetry instrumentation for DSPy

Project description

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

Project details


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.6.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_dspy-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 2bec6d9c3a5e5368888be56b5ff38feb07b8e08254dc14615e5d00aa2bf02a37
MD5 ba4faff22809fd709058439d1d41aef0
BLAKE2b-256 604eb616c5a110f66c6fd007038cd139b510ad2f4d7175e5e28e56ae145b2f80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_dspy-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 43c4bb4ff00a8c7ca2f4bba7c317fc0c2ecae583072716f483cc748fb8d71c9f
MD5 f024add5d8888691e2f3411b50f074ae
BLAKE2b-256 fca6dd02294b7848ce5157347664489845c394c2ec79a891d4ae2b53682b376f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page