Skip to main content
Monitor custom AI agents and multi-framework agentic applications with Fiddler using OpenTelemetry’s native instrumentation.

What You’ll Learn

In this guide, you’ll learn how to:
  • Set up OpenTelemetry tracing for custom agent frameworks
  • Configure Fiddler as your OTLP endpoint with proper authentication
  • Map agent attributes to Fiddler’s semantic conventions
  • Create instrumented LLM and tool spans with required attributes
  • Verify traces in the Fiddler dashboard
Time to complete: ~10-15 minutes
When to Use Raw OpenTelemetryThis guide is for advanced scenarios requiring full manual OTLP control:
  • Multi-framework environments requiring unified observability across different agent frameworks
  • Existing OpenTelemetry infrastructure where you want to route Fiddler traces through your own OTel pipeline
  • Advanced control over trace sampling, batch processing, and attribute mapping
When to Use Fiddler SDKs Instead (recommended for most users):SDKs provide automatic instrumentation and require significantly less code. Use raw OpenTelemetry only when SDKs don’t fit your use case.

Prerequisites

Before you begin, ensure you have:
  • Fiddler Account: An active account with a GenAI application created
  • Python 3.10+
  • OpenTelemetry Packages:
    • pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
  • LLM Provider (for examples): OpenAI API key or similar
  • Fiddler Access Token: Get your token from Settings > Credentials
For a complete working example with advanced patterns, download the Advanced OpenTelemetry Notebook from GitHub or open it in Google Colab.
1

Create Fiddler Application

  1. Log in to your Fiddler instance and navigate to GenAI Applications
  2. Select “Add Application” to create a new application
  3. Copy your Application ID - This must be a valid UUID4 format (e.g., 550e8400-e29b-41d4-a716-446655440000)
  4. Get your Access Token from Settings > Credentials
Important: Keep your Application ID and Access Token secure. You’ll need both for the next steps.
2

Configure Environment Variables

Set up your environment to connect to Fiddler’s OTLP endpoint:
Environment Variable Breakdown:Python Configuration (alternative to environment variables):
Tip: Store credentials in a .env file and use python-dotenv for local development:
3

Initialize OpenTelemetry

Set up OpenTelemetry with Fiddler’s OTLP exporter:
What This Does:
  • TracerProvider: Manages trace generation
  • OTLPSpanExporter: Exports spans to Fiddler via OTLP protocol
  • BatchSpanProcessor: Batches spans for efficient network transmission
Local Debugging: Add a console exporter to see traces locally while developing:
4

Instrument Your Agent

Create instrumented spans for your agent’s operations. Fiddler requires specific attributes to properly categorize and visualize your agent traces.Required Fiddler AttributesResource Level (set via environment variable):
  • application.id - UUID4 of your Fiddler application
Span Level (required for each span):
  • fiddler.span.type - Type of operation: "chain", "tool", "llm", or "agent"
Recommended: Decorate functions with start_as_current_spanOpenTelemetry’s tracer.start_as_current_span() works both as a context manager (with ... as span:) and as a function decorator. When a span should wrap an entire function — which is the common case for tools, LLM calls, and agent entry points — the decorator form is far less verbose: it starts the span on entry and ends it on return automatically. Inside the function, call trace.get_current_span() to set Fiddler attributes on the active span.Reach for the with block only when you need a span narrower than a whole function (for example, instrumenting a single section of a larger function). Both forms are pure OpenTelemetry and require no Fiddler SDK.Example: Simplified Travel Agent
Key Implementation Details:
  • Decorator form: @tracer.start_as_current_span("name") wraps the whole function; retrieve the span inside with trace.get_current_span()
  • Chain Spans: Use fiddler.span.type = "chain" for high-level workflows
  • LLM Spans: Include model, system prompt, user input, output, and token usage
  • Tool Spans: Include tool name, input JSON, and output JSON
  • Nested Spans: A decorated function called from within another decorated function automatically becomes a child span, building the trace hierarchy
Simpler alternative: Install fiddler-otel to skip all the manual OTLP configuration and attribute boilerplate. The SDK’s start_as_current_span() method handles span type enforcement and attribute propagation automatically — no need to set fiddler.span.type, gen_ai.agent.name, or gen_ai.agent.id on every span manually. Typed span wrappers like FiddlerGeneration and FiddlerTool provide helper methods such as set_model() and set_tool_name() instead of raw set_attribute() calls. See Manual Instrumentation in the integration guide.
5

Verify Monitoring

  1. Run your instrumented code using the example above
  2. Wait 1-2 minutes for traces to appear in Fiddler
  3. Navigate to GenAI Applications in your Fiddler instance
  4. Verify application status changes to Active
  5. View traces to see your agent spans, hierarchy, and attributes
Success Criteria:✅ Application shows as Active in GenAI Applications ✅ Traces appear in the Explorer ✅ Span hierarchy shows chain → LLM → tools relationship ✅ fiddler.span.type is set on every span ✅ LLM token usage is tracked ✅ Tool inputs and outputs are captured
Verification Tip: Check the trace timeline view to see the execution flow of your agent, including which tools were called and how long each operation took.

Attribute Reference

Required Attributes

Resource Level: Span Level:

Optional Attributes

Agent Identification:
Set agent attributes on every span. gen_ai.agent.name and gen_ai.agent.id are optional, but if you include them, set both on every span within the trace. Fiddler uses these attributes to attribute spans to the correct agent — spans missing these fields will be unattributed even if other spans in the same trace carry them.
Conversation Tracking: LLM Span Attributes: Tool Span Attributes: Custom User-Defined Attributes:

Troubleshooting

Common Issues

Problem: Application not showing as “Active” Solutions:
  1. Verify environment variables are set correctly
  2. Check that OTEL_EXPORTER_OTLP_ENDPOINT includes your Fiddler instance URL
  3. Ensure OTEL_EXPORTER_OTLP_HEADERS contains valid authorization token and application ID
  4. Add console exporter to verify spans are being generated locally
  5. Check network connectivity: curl -I https://your-instance.fiddler.ai
Problem: ModuleNotFoundError for OpenTelemetry packages Solutions:
Problem: Spans not appearing in Fiddler Solutions:
  1. Verify required attributes are set:
  2. Check resource attributes:
  3. Enable console exporter for debugging:
Problem: Authentication errors (401 Unauthorized) Solutions:
  1. Regenerate your access token from Fiddler Settings > Credentials
  2. Verify header format: authorization=Bearer <token>,fiddler-application-id=<uuid>
  3. Ensure no extra spaces in header values
  4. Check token hasn’t expired
Problem: Invalid Application ID error Solutions:
  1. Copy Application ID directly from Fiddler UI
  2. Verify UUID4 format: 550e8400-e29b-41d4-a716-446655440000
  3. Ensure no extra quotes or whitespace

Configuration Options

Basic Configuration

Advanced Configuration

High-Volume Applications (Batch Processing Tuning):
Environment Variable Configuration:
Sampling for Production (Reduce Volume):
Compression (Reduce Network Usage):
Using FiddlerClient Alternative (Simplified Setup):
Deprecation notice: Importing FiddlerClient and other core symbols (trace, get_current_span, FiddlerSpan, FiddlerGeneration, FiddlerChain, FiddlerTool, get_client, set_conversation_id) directly from fiddler_langgraph is deprecated and will be removed in a future release. Import from fiddler_otel instead: from fiddler_otel import FiddlerClient.
If you have fiddler-otel installed, you can use FiddlerClient for simplified setup — it handles OTLP configuration automatically. There are two levels of abstraction:Option 1: Get a pre-configured tracer (use raw OTel spans, but skip OTLP configuration):
Option 2: Use SDK span wrappers (typed helper methods, automatic attribute propagation):
Both approaches handle OTLP configuration automatically. For graceful exit (e.g. servers or short scripts), call client.shutdown() (or await client.ashutdown() in async) so buffered spans are sent before the process exits. See Manual Instrumentation for complete span wrapper documentation.

Next Steps

Now that you have OpenTelemetry integration working: