Skip to main content

Guardrails OpenTelemetry Integration

Overview

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

Installation

  1. Install traceAI Guardrails
pip install traceAI-guardrails

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="guardrails_app"
)

Configure Guardrails Instrumentation

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

from traceai_guardrails import GuardrailsInstrumentor

GuardrailsInstrumentor().instrument(tracer_provider=trace_provider)

Create Guardrails Components

Set up your Guardrails client with built-in observability.

from guardrails import Guard

guard = Guard()
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current temperature for a given location.",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "City and country e.g. Bogotá, Colombia"
                }
            },
            "required": [
                "location"
            ],
            "additionalProperties": False
        },
        "strict": True
    }
}]

result = guard(
    messages=[
            {
                "role": "user",
                "content": "What is the weather in Delhi?",
            },
        ],
    model="gpt-4o",
    tools=tools

)

print(f"{result}")

Metadata

Release files for traceAI-guardrails 0.2.0

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-guardrails 0.2.0
File Size Uploaded
traceai_guardrails-0.2.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-guardrails 0.2.0
File Interpreter ABI Platform
traceai_guardrails-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / traceai_guardrails-0.2.0.tar.gz

Download URL traceai_guardrails-0.2.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7d97ca04f66d87e6bf50e70a94a838d78dad90d401c099851ebf017209027a2c
BLAKE2b-256 checksum
How to use checksums
11dcf34e6e0d91b3afc089ec306b4c1af42ea9438ed2b7f13ac3cab8c6032bae
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_guardrails-0.2.0-py3-none-any.whl

Download URL traceai_guardrails-0.2.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a918020215b9e49bcfd8a779641ede163e7f00811d023e090bd7df4a6a2925b
BLAKE2b-256 checksum
How to use checksums
70cb02d7a5066cf08e3c15c56d77de99625d241d4748daa9073cc8df887b4113
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.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

3 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