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.3.0.tar.gz (19.1 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.3.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fiddler_strands-0.3.0.tar.gz
  • Upload date:
  • Size: 19.1 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.3.0.tar.gz
Algorithm Hash digest
SHA256 0a9d8b84d44c15ea71850226437de04acbb7894c8cf58b13aa12172007bd2ab1
MD5 563194ef0963037dd10b4a6db7aad839
BLAKE2b-256 1e80b3193adba99eb2714e10948caa1288cecf8ffa271383114e74fefbb23907

See more details on using hashes here.

Provenance

The following attestation bundles were made for fiddler_strands-0.3.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.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fiddler_strands-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b3949b71bc5a63bf67dca808179afda5e23516d961a12a959e9b203541f3ed5
MD5 c4c699fb6aeba171fa4d0c0fc6d9830b
BLAKE2b-256 5a4e7a141e920c9b16ef4b67533a1358f823775b0b831e6b099e982c6f57a79b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fiddler_strands-0.3.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