Skip to main content
Splunk Agent Observability supports logging traces from Strands Agents SDK applications using OpenTelemetry.

Set up OpenTelemetry

To log Strands Agents using Splunk Agent Observability, the first step is to set up OpenTelemetry.
1

Installation

Add the OpenTelemetry packages to your project:
The opentelemetry-api and opentelemetry-sdk packages provide the core OpenTelemetry functionality. The opentelemetry-exporter-otlp package enables sending traces to Splunk Agent Observability’s OTLP endpoint.
2

Create environment variables for your Splunk Agent Observability settings

Set environment variables for your Splunk Agent Observability settings, for example in a .env file. These environment variables are consumed by the SplunkAOSpanProcessorto authenticate and route traces to the correct Splunk Agent Observability Project and Agent Stream:
3

Self hosted deployments: Set the OTel endpoint

Skip this step if you are using a hosted version.
The OTel endpoint is different from Splunk Agent Observability’s regular API endpoint and is specifically designed to receive telemetry data in the OTLP format.If you are using:
  • A cloud deployment, then you don’t need to provide a custom OTel endpoint. The default endpoint <your-splunk-ao-api-url>/otel/traces will be used automatically.
  • A self-hosted deployment, replace the <your-splunk-ao-api-url>/otel/traces endpoint with your deployment URL. The format of this URL is based on your console URL, appending /otel/traces.
The convention is to store this in the SPLUNK_AO_CONSOLE_URL environment variable. For example:
4

Initialize and create the Splunk Agent Observability span processor

The SplunkAOSpanProcessor automatically configures authentication and metadata using your environment variables. It also:
  • Auto-builds OTLP headers using your Splunk Agent Observability credentials
  • Configures the correct OTLP trace endpoint
  • Registers a batch span processor that exports traces to Splunk Agent Observability

Log a Strands ADK agent using OpenTelemetry

Once OpenTelemetry is configured, you can use the OTel capabilities of Strands to log traces.
1

Import the Strands Agent telemetry package

The Strands Agents SDK has telemetry support out of the box. Start by importing StrandsTelemetry with the following code:
2

Set up the exporter

You can now set up an OTel exporter for your Strands Agent:
When you run your Strands Agent code, traces will be logged to Splunk Agent Observability.

Opt in to experimental OpenTelemetry semantic conventions

Starting in strands-agents v1.34.0, the Strands Agents SDK can emit generative AI traces using either the legacy OpenTelemetry semantic conventions or the newer experimental conventions:
  • Legacy mode (default) — uses attributes such as gen_ai.system along with legacy event shapes.
  • Experimental mode — follows the latest OpenTelemetry generative AI semantic conventions, using gen_ai.provider.name and structured gen_ai.client.inference.operation.details events that carry inputs, outputs, and system instructions.
Splunk Agent Observability automatically detects and maps both modes, so traces from either mode will appear in your Splunk Agent Observability Agent Stream without any changes to your Splunk Agent Observability setup. If you want to opt in to the experimental conventions, set the following environment variable before your Strands Agent starts:
OTEL_SEMCONV_STABILITY_OPT_IN is read by the Strands Agents SDK at startup. Make sure it is exported in your process environment (or loaded from your .env file) before StrandsTelemetry is initialized.

Full example

Here is a full example based off the Strands Agent quickstart. You can find this project in the Splunk Agent Observability SDK examples repo. To run this example, create a .env file with the following values set, or set them as environment variables:
.env
Remember to update these to match your Splunk Agent Observability API key, AWS Bedrock token, Splunk Agent Observability OTel endpoint, project name, and Agent Stream name.