Skip to main content

Core OpenTelemetry instrumentation library for Fiddler GenAI observability

Project description

fiddler-otel

Core OpenTelemetry instrumentation library for Fiddler GenAI observability. This is the foundation package used by all Fiddler framework integrations (fiddler-langgraph, fiddler-langchain).

Installation

pip install fiddler-otel

Quick Start

Using the @trace decorator

The simplest way to instrument any Python function — synchronous or async:

from fiddler_otel import FiddlerClient, trace

client = FiddlerClient(
    application_id="YOUR_APPLICATION_ID",
    api_key="YOUR_API_KEY",
    url="https://your-instance.fiddler.ai",
)

@trace(span_type="generation", name="my_llm_call")
def call_llm(prompt: str) -> str:
    # your LLM call here
    return response

@trace(span_type="chain")
async def run_pipeline(user_input: str) -> str:
    result = call_llm(user_input)
    return result

Using span wrappers manually

For fine-grained control over span attributes:

from fiddler_otel import FiddlerClient, FiddlerGeneration, FiddlerChain, FiddlerTool

client = FiddlerClient(
    application_id="YOUR_APPLICATION_ID",
    api_key="YOUR_API_KEY",
    url="https://your-instance.fiddler.ai",
)

with client.start_span("my_agent", span_type="chain") as chain_span:
    gen = FiddlerGeneration(client.start_span("llm_call"))
    with gen as span:
        span.set_input("What is the capital of France?")
        response = call_llm("What is the capital of France?")
        span.set_output(response)
        span.set_usage(input_tokens=10, output_tokens=5, total_tokens=15)

Multi-turn Conversations

Link multiple agent invocations into a single conversation:

from fiddler_otel import set_conversation_id
import uuid

set_conversation_id(str(uuid.uuid4()))

# All spans created after this call carry the same conversation_id
result = my_agent(user_message)

Local JSONL Capture

Write spans to a local file in addition to sending them directly to Fiddler. Useful for local debugging or auditing.

Note: jsonl_capture_enabled=True is additive — spans are still exported to Fiddler. To stop direct export, set otlp_enabled=False (see Offline / S3 Routing Mode below).

client = FiddlerClient(
    application_id="...",
    api_key="...",
    url="...",
    jsonl_capture_enabled=True,
    jsonl_file_path="trace_data.jsonl",
)

Or via environment variables:

FIDDLER_JSONL_ENABLED=true \
FIDDLER_JSONL_FILE=trace_data.jsonl \
python my_agent.py

Console Tracing (Development)

Print all spans to stdout during development.

Note: console_tracer=True is additive — spans are still exported to Fiddler. It does not suppress direct OTLP export.

client = FiddlerClient(
    application_id="...",
    api_key="...",
    url="...",
    console_tracer=True,
)

Offline / S3 Routing Mode

Use otlp_enabled=False to stop all direct OTLP export to Fiddler. Combined with otlp_json_capture_enabled=True, spans are written to local .json files in standard OTLP JSON format (ExportTraceServiceRequest envelope) that can be ingested by the Fiddler S3 connector.

When otlp_enabled=False, api_key and url are not required.

Why is application_id still required? Even when not connecting to Fiddler directly, application_id is embedded in every trace file as a resource attribute. The Fiddler S3 connector reads this attribute to route ingested traces to the correct application in your Fiddler account. Obtain the UUID4 from your Fiddler application dashboard.

client = FiddlerClient(
    application_id="YOUR_APPLICATION_ID",  # from your Fiddler dashboard — embedded in trace files
    otlp_enabled=False,                    # no spans sent directly to Fiddler
    otlp_json_capture_enabled=True,        # write OTLP JSON files locally
    otlp_json_output_dir="./trace_output",  # directory for output files (created if absent)
)

Each export batch produces one file named fiddler_trace_<timestamp>_<hex>.json inside otlp_json_output_dir. The directory is created automatically if it does not exist. These files can be uploaded to object storage and ingested by the Fiddler S3 connector without any reformatting.

Public API

Symbol Description
FiddlerClient Main client — configures the tracer and exports spans to Fiddler
FiddlerSpan Base span wrapper with set_input, set_output, set_attribute
FiddlerGeneration LLM span wrapper — adds set_usage, set_messages, set_context
FiddlerChain Chain/pipeline span wrapper
FiddlerTool Tool call span wrapper
trace Decorator for automatic span creation around any function
get_current_span Get the active Fiddler span inside a traced function
set_conversation_id Link multiple invocations into one conversation
get_client Return the global singleton FiddlerClient

Context Isolation

fiddler-otel uses its own isolated OpenTelemetry context that does not interfere with any existing global tracer in your application. If you already use OpenTelemetry for infrastructure tracing, Fiddler spans will not appear in your infrastructure traces and vice versa.

Framework Integrations

Package Framework Install
fiddler-langgraph LangGraph + LangChain v0.x pip install fiddler-langgraph
fiddler-langchain LangChain V1 (create_agent) pip install fiddler-langchain

Both integration packages depend on fiddler-otel and re-export its core symbols, so you typically only need to install the integration package for your framework.

Requirements

  • Python 3.10+
  • opentelemetry-api >= 1.27.0
  • opentelemetry-sdk >= 1.27.0
  • opentelemetry-exporter-otlp-proto-http >= 1.27.0
  • pydantic >= 2.0

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_otel-1.1.1.tar.gz (23.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_otel-1.1.1-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file fiddler_otel-1.1.1.tar.gz.

File metadata

  • Download URL: fiddler_otel-1.1.1.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fiddler_otel-1.1.1.tar.gz
Algorithm Hash digest
SHA256 0db3b11992e5470eed5ee107c989058edaedf3691199f932122a9c62d5e6d8d2
MD5 caff7d7f8779488bc2028788f3ffcca7
BLAKE2b-256 13018b355d9343769004eca83d485061cfa2ddf62a9b31ec5845766acc2f8325

See more details on using hashes here.

Provenance

The following attestation bundles were made for fiddler_otel-1.1.1.tar.gz:

Publisher: publish.yml on fiddler-labs/fiddler-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_otel-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: fiddler_otel-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fiddler_otel-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f7bd7d14d33287c63803f5873475306f5da8cc1f2e999c60133a8c667f52d30
MD5 c3022260d79e7cd139b309298dbb135c
BLAKE2b-256 6a0519d94dfe5d22a6d2b34cd471f9007bcc8f8f620a5a929aef5f646da7b6b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fiddler_otel-1.1.1-py3-none-any.whl:

Publisher: publish.yml on fiddler-labs/fiddler-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