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:
- Set up OpenTelemetry with Splunk Agent Observability
- Create an agent with framework instrumentation
- Expose an entry point for the experiment runner
- Run the experiment
How it works
When you run an experiment with a custom function, Splunk Agent Observability’s experiment runner:- Creates an experiment and sets the
experiment_idin the Splunk Agent Observability context. - For each row in the dataset, it calls your function and wraps the call with dataset context (input, ground truth, and metadata).
- The
SplunkAOSpanProcessorreads this context and attaches it to every OTel span your framework creates. - 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 aTracerProvider and attach the SplunkAOSpanProcessor. This processor automatically configures authentication and the OTLP endpoint using your environment variables.
agent.py
agent.py
Create the agent
Set up your agent with your framework of choice. The key requirement is that the framework emits OTel spans through the registeredTracerProvider.
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
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
Userun_experiment to iterate over the dataset, call your agent function, and evaluate the results with evaluators.
main.py
Key parameters
Ground truth
When your dataset includes aground_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.