- A project represents a distinct application. For example - a customer facing chatbot and an internal HR chatbot would be 2 separate projects.
- A Agent Stream represents a distinct environment in that project that you want to monitor. For example, a dev Agent Stream for your development work, a staging Agent Stream for your staging environment, and a production Agent Stream for your production application.
Structure of Agent Streams
When logging applications, Agent Streams are made up of zero or more sessions, which are in turn made up of traces, which contain spans. Experiments can be thought of as a single session, containing multiple traces made up of spans.- Sessions represent logical groupings of traces for actions involving an AI that may contain multiple steps. For example, in a chatbot, the entire conversation with a single user would be a session.
- Traces represent one complete interaction with an AI that may contain multiple calls and interactions. For example, inside a chatbot app sending a single message, having the AI handle it using tool calls or RAG, then returning a response, would be a single trace.
- Spans represent distinct operations inside a trace. Each LLM call, tool call, or step in an agentic workflow would be an individual span. For example, in a chatbot app the initial message sent to the LLM, calls to tools based off the LLM response, follow-up LLM calls would all be separate spans.
SplunkAOLogger object that is configured to point to a specific project and Agent Stream, then from there you can create sessions and traces, and add log spans to a trace. This logger can be created manually, or automatically using a range of wrappers, decorators and integrations with third party SDKs.
Initial setup
To log to Splunk Agent Observability, you need to configure a connection to Splunk Agent Observability using an API key and optionally a URL for an on-premises, standalone, or custom deployment, as well as setting the project and Agent Stream you want to log to.API key
To get started building with Splunk Agent Observability, you need to configure your API key, and optionally the URL of your Splunk Agent Observability deployment if you are using a custom hosted, or self deployed version. These are set as environment variables. In development you can use a.env file for these, for a production deployment make sure you configure these correctly for your deployment platform.
If you are using the free version of Splunk Agent Observability, there is no need to set the
SPLUNK_AO_CONSOLE_URL environment variable.Project and Agent Stream
Both the project and Agent Stream can be configured as environment variables, or directly in code. Agent Streams can be created up front in the Splunk Agent Observability UI, or automatically in code. If you log to an Agent Stream that doesn’t exist, it will be created automatically for you.Set the project and Agent Stream using environment variables
The advantage of using environment variables to set your project and Agent Stream is that you can share code across deployments and configure those deployments separately, for example to share the same project but log to different Agent Streams.Set the project and Agent Stream in code
The advantage of setting in code is you have more granular control, for example logging different parts of your application to different Agent Streams. You can set these in code in two ways - set it at the context level so that it is shared by all logging calls, or set it at an individual logger level. To set at the context level, use this code. After running this code, every trace will go to the specified Agent Stream for the specified project.Logging flow
The typical logging flow follows these steps: Starting sessions is optional - if you don’t start a session, then all traces are automatically each logged to new autogenerated sessions. Using the Splunk Agent Observability SDK you can either do all these steps manually, or you can use a range of wrappers, decorators and integrations with third-party SDKs, where most of this is handled for you.Logging components
Splunk Agent Observability provides 3 ways to log your application code:- The Splunk Agent Observability Logger - You can create a logger, and manually manage sessions, traces, spans and more. This logger can be passed around your application to create traces and add spans as needed.
- Log Decorator - You can decorate or wrap functions with the log decorator to have spans created automatically. If you don’t have an active session or trace, one will be created. You can also access the logger used by the decorator for manual control.
- Third-party integrations - Splunk Agent Observability integrates SDKs like the OpenAI SDK, the OpenAI Agents SDK, and LangChain/LangGraph. These integrations manage logging for you, automatically creating sessions, traces and spans as needed.
- In a chatbot app using LangGraph, you can start sessions for each distinct user conversation with the Splunk Agent Observability context, then have the Splunk Agent Observability LangGraph callback log each chat message as a separate trace automatically.
- In an agentic app, you can wrap top level calls with the
logdecorator to start a trace, access the log that was created by the decorator to add workflow spans, then have spans added automatically under these workflow spans using the OpenAI Agents SDK integration.
Next steps
Basic logging components
Splunk Agent Observability logger
Log with full control over sessions, traces, and spans using the Splunk Agent Observability logger.
Log decorator
Quickly add logging to your code with the log decorator and wrapper.
Splunk Agent Observability context
Manage logging using the Splunk Agent Observability context manager.
OpenTelemetry and OpenInference
OpenTelemetry and OpenInference
Learn how to integrate Splunk Agent Observability with OpenTelemetry and OpenInference for comprehensive observability and tracing.
Google ADK
Learn how to integrate a Google ADK project with Splunk Agent Observability using OpenTelemetry and OpenInference.
Strands Agents
Learn how to integrate a Strands Agents project with Splunk Agent Observability using OpenTelemetry.
Vercel AI SDK
Learn how to integrate a Vercel AI SDK project with Splunk Agent Observability using OpenTelemetry.
LLM SDK integrations
OpenAI wrapper
Automatically log calls to the OpenAI SDK with a wrapper.
Agent framework integrations
CrewAI event listener
Automatically log all the steps in your CrewAI application with the Splunk Agent Observability event listener.
LangChain/LangGraph callback
Automatically log all the steps in your LangChain or LangGraph application with the Splunk Agent Observability callback.
OpenAI Agents trace processor
Automatically log all the steps in your OpenAI Agent SDK apps using the Splunk Agent Observability trace processor.