Skip to main content
If your application uses a framework with built-in OpenTelemetry instrumentation, you can run experiments against it using Splunk Agent Observability’s SplunkAOSpanProcessor. The span processor captures OTel traces and routes them to the experiment automatically — no need to use the Splunk Agent Observability log decorator or manual logging. This is useful when you are working with frameworks like Microsoft Agent Framework, Google ADK, Pydantic AI, or any other framework that emits OTel spans. In this guide you will:
  1. Set up OpenTelemetry with Splunk Agent Observability
  2. Create an agent with framework instrumentation
  3. Expose an entry point for the experiment runner
  4. Run the experiment

How it works

When you run an experiment with a custom function, Splunk Agent Observability’s experiment runner:
  1. Creates an experiment and sets the experiment_id in the Splunk Agent Observability context.
  2. For each row in the dataset, it calls your function and wraps the call with dataset context (input, ground truth, and metadata).
  3. The SplunkAOSpanProcessor reads this context and attaches it to every OTel span your framework creates.
  4. Spans are exported to Splunk Agent Observability’s OTLP endpoint with the experiment ID, routing them to the experiment instead of a regular Agent Stream.
Because the experiment runner manages the trace lifecycle, you must disable Splunk Agent Observability’s native logger to avoid duplicate traces. Set SPLUNK_AO_LOGGING_DISABLED=true before importing your agent code.

Prerequisites

Install the Splunk Agent Observability SDK with OpenTelemetry support, plus any framework-specific packages:
Terminal

Set up environment variables

Configure your Splunk Agent Observability credentials and disable the native logger:
.env

Set up OpenTelemetry with Splunk Agent Observability

Create a TracerProvider and attach the SplunkAOSpanProcessor. This processor automatically configures authentication and the OTLP endpoint using your environment variables.
agent.py
Then enable your framework’s instrumentation. For example, with Microsoft Agent Framework:
agent.py
Set enable_sensitive_data=True to capture LLM inputs and outputs in your traces. If set to False, only span metadata (timing, token counts, etc.) is sent.

Create the agent

Set up your agent with your framework of choice. The key requirement is that the framework emits OTel spans through the registered TracerProvider.
agent.py

Create the experiment entry point

The experiment runner calls your function once per dataset row. Your function receives the row data and must return a string result.
agent.py
The function should handle both str and dict inputs, since the experiment runner passes the parsed row data which can be in either format depending on your dataset structure.

Run the experiment

Use run_experiment to iterate over the dataset, call your agent function, and evaluate the results with evaluators.
main.py
Set SPLUNK_AO_LOGGING_DISABLED=true before importing your agent module. The agent module initializes OTel on import, and the native logger must be disabled before that happens to avoid conflicts.

Key parameters

Ground truth

When your dataset includes a ground_truth field, this value is attached to the OTel spans as ground truth. Evaluators like Ground Truth Adherence use this to evaluate the agent’s response. The experiment runner uses splunk_ao_dataset_context to attach the ground truth to the OTel context, so it is available to the SplunkAOSpanProcessor without any manual configuration.

Supported frameworks

Any framework with OpenTelemetry instrumentation works with this approach. See the framework-specific guides for OTel setup details:

Microsoft Agent Framework

Built-in OTel instrumentation, no extra packages needed.

Google ADK

Integrate Google Agent Development Kit with Splunk Agent Observability via OTel.

Pydantic AI

Use Pydantic AI’s OTel support with Splunk Agent Observability.

Strands Agents

Integrate Strands Agents with Splunk Agent Observability via OTel.

Next steps

Run experiments in code

Learn about all experiment approaches including prompt templates and custom functions.

OpenTelemetry overview

Learn more about Splunk Agent Observability’s OpenTelemetry integration for logging and monitoring.

Evaluators reference

Explore the full list of available evaluators for experiments.

Datasets

Learn how to create and manage datasets for experiments.