Skip to main content

Fiddler SDK for Strands Agent instrumentation with OpenTelemetry

Project description

Fiddler Strands SDK

Python 3.10+ License: Apache-2.0

OpenTelemetry instrumentation SDK for Strands AI agents, providing automatic observability and monitoring capabilities through Fiddler's platform.

Features

  • 🎯 Automatic Instrumentation: Zero-code instrumentation of Strands agents using OpenTelemetry
  • 🔍 Built-in Observability: Automatic logging hooks for agent interactions
  • 📊 Fiddler Integration: Custom span processors for enhanced trace analysis
  • 🛠️ Extensible: Easy to add custom hooks and processors
  • 🚀 Production Ready: Built on OpenTelemetry standards

Installation

Using uv (Recommended)

# Install the SDK
uv add fiddler-strands

Using pip

pip install fiddler-strands

Quick Start

Prerequisites

Before using the SDK, ensure you have:

  • Fiddler platform access with API credentials
  • OpenAI API key (if using OpenAI models)
  • Configure environment variables:
    • FIDDLER_ENDPOINT: Your Fiddler platform URL
    • FIDDLER_TOKEN: Your Fiddler API token
    • FIDDLER_APPLICATION_UUID: Your application UUID from Fiddler

See the full documentation for detailed configuration steps.

Basic Usage

import os
from strands import Agent
from strands.models.openai import OpenAIModel
from strands.telemetry import StrandsTelemetry
from fiddler_strandsagents import StrandsAgentInstrumentor

strands_telemetry = StrandsTelemetry()
strands_telemetry.setup_otlp_exporter()
strands_telemetry.setup_console_exporter()
# Enable automatic instrumentation
StrandsAgentInstrumentor(strands_telemetry).instrument()

# Create your agent as usual - LoggingHook will be automatically injected
model = OpenAIModel(api_key=os.getenv("OPENAI_API_KEY"))
agent = Agent(model=model, system_prompt="You are a helpful assistant")

# Use your agent - all interactions will be automatically instrumented
response = agent("Hello, how are you?")

Note: The OTLP exporter requires Fiddler credentials to be configured as environment variables.

API Reference

StrandsAgentInstrumentor

The main instrumentor class for automatic agent instrumentation.

from fiddler_strandsagents import StrandsAgentInstrumentor

instrumentor = StrandsAgentInstrumentor()

# Enable instrumentation
instrumentor.instrument()

# Check if instrumentation is active
is_active = instrumentor.is_instrumented_by_opentelemetry

# Disable instrumentation
instrumentor.uninstrument()

Helper Functions

The SDK provides helper functions to add custom metadata to your telemetry spans:

set_conversation_id(agent, conversation_id)

Set a unique conversation ID for tracking related interactions:

from fiddler_strandsagents import set_conversation_id

set_conversation_id(agent, 'session_1234567890')

set_session_attributes(agent, **kwargs)

Add custom session-level attributes to track business context:

from fiddler_strandsagents import set_session_attributes

set_session_attributes(agent,
    role='customer_support',
    cost_center='travel_desk',
    region='us-west'
)

set_span_attributes(obj, **kwargs)

Add custom attributes to specific components (agents, models, or tools):

from fiddler_strandsagents import set_span_attributes

# Add attributes to a model
set_span_attributes(model, model_id='gpt-4o-mini', temperature=0.7)

# Add attributes to a tool
set_span_attributes(tool, department='search', version='2.0')

set_llm_context(model, context)

Set additional context for LLM interactions:

from fiddler_strandsagents import set_llm_context

set_llm_context(model, 'Available options: Option A, Option B, Option C...')

Getter Functions

Retrieve previously set metadata:

from fiddler_strandsagents import (
    get_conversation_id,
    get_session_attributes,
    get_span_attributes
)

conversation_id = get_conversation_id(agent)
attributes = get_session_attributes(agent)
span_attrs = get_span_attributes(model)

License

This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.

Support

Examples and Development

For example scripts and development information, please visit the GitHub repository.

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

fiddler_strands-0.4.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

fiddler_strands-0.4.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file fiddler_strands-0.4.0.tar.gz.

File metadata

  • Download URL: fiddler_strands-0.4.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fiddler_strands-0.4.0.tar.gz
Algorithm Hash digest
SHA256 07b5c3bb75bd8d08d69794edea95787c6b6f352a784d3c6c075adfea3a6cca9a
MD5 07f6d7863cc72351bc3bcf8a905a971e
BLAKE2b-256 c7c657bddd1725fc3bd85784e6e1ff45d5a6e24a8fc35ca9122df510539f25d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fiddler_strands-0.4.0.tar.gz:

Publisher: publish.yml on fiddler-labs/fiddler-strands-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fiddler_strands-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fiddler_strands-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 897d842ea0d65bb42e30f41451b3b0de3a85f664f9d57939f13c608bcb3d59de
MD5 cb15d266a72c37b814a8f6b24d40c284
BLAKE2b-256 7987a6329bb423a41a9f280bb8106886fbb0d51cda7466bd5f77911ea07db045

See more details on using hashes here.

Provenance

The following attestation bundles were made for fiddler_strands-0.4.0-py3-none-any.whl:

Publisher: publish.yml on fiddler-labs/fiddler-strands-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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