Skip to main content
If your application uses a framework with built-in OpenTelemetry instrumentation, you can run experiments against it using Galileo’s GalileoSpanProcessor. The span processor captures OTel traces and routes them to the experiment automatically — no need to use the Galileo 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 Galileo
  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, Galileo’s experiment runner:
  1. Creates an experiment and sets the experiment_id in the Galileo 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 GalileoSpanProcessor reads this context and attaches it to every OTel span your framework creates.
  4. Spans are exported to Galileo’s OTLP endpoint with the experiment ID, routing them to the experiment instead of a regular Log stream.
Because the experiment runner manages the trace lifecycle, you must disable Galileo’s native logger to avoid duplicate traces. Set GALILEO_LOGGING_DISABLED=true before importing your agent code.

Prerequisites

Install the Galileo SDK with OpenTelemetry support, plus any framework-specific packages:
Terminal

Set up environment variables

Configure your Galileo credentials and disable the native logger:
.env

Set up OpenTelemetry with Galileo

Create a TracerProvider and attach the GalileoSpanProcessor. 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 metrics.
main.py
Set GALILEO_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. Metrics like Ground Truth Adherence use this to evaluate the agent’s response. The experiment runner uses galileo_dataset_context to attach the ground truth to the OTel context, so it is available to the GalileoSpanProcessor 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 Galileo via OTel.

Pydantic AI

Use Pydantic AI’s OTel support with Galileo.

Strands Agents

Integrate Strands Agents with Galileo via OTel.

Next steps

Run experiments in code

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

OpenTelemetry overview

Learn more about Galileo’s OpenTelemetry integration for logging and monitoring.

Metrics reference

Explore the full list of available metrics for experiments.

Datasets

Learn how to create and manage datasets for experiments.