Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions examples/tracing/strands-agents/strands_agents_tracing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "2722b419",
"metadata": {},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openlayer-ai/openlayer-python/blob/main/examples/tracing/strands-agents/strands_agents_tracing.ipynb)\n",
"\n",
"\n",
"# <a id=\"top\">Strands Agents quickstart</a>\n",
"\n",
"This notebook shows how to export traces captured by [Strands Agents](https://strandsagents.com/latest/) to Openlayer. The integration is done via the Openlayer's [OpenTelemetry endpoint](https://www.openlayer.com/docs/integrations/opentelemetry)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0156bc8f",
"metadata": {},
"outputs": [],
"source": [
"!pip install 'strands-agents[otel]'"
]
},
{
"cell_type": "markdown",
"id": "75c2a473",
"metadata": {},
"source": [
"## 1. Set the environment variables"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f3f4fa13",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# Env variables pointing to Openlayer's OpenTelemetry endpoint\n",
"os.environ[\"OTEL_EXPORTER_OTLP_ENDPOINT\"] = \"https://api.openlayer.com/v1/otel\"\n",
"os.environ[\"OTEL_EXPORTER_OTLP_HEADERS\"] = \"Authorization=Bearer YOUR_OPENLAYER_API_KEY_HERE, x-bt-parent=pipeline_id:YOUR_PIPELINE_ID_HERE\"\n",
"\n",
"# AWS credentials for Strands Agents – other authentication methods are available as well\n",
"os.environ[\"AWS_ACCESS_KEY_ID\"] = \"YOUR_AWS_ACCESS_KEY_ID_HERE\"\n",
"os.environ[\"AWS_SECRET_ACCESS_KEY\"] = \"YOUR_AWS_SECRET_ACCESS_KEY_HERE\""
]
},
{
"cell_type": "markdown",
"id": "6cbd3831",
"metadata": {},
"source": [
"## 2. Configure Strands telemetry"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2062d8b",
"metadata": {},
"outputs": [],
"source": [
"from strands.telemetry import StrandsTelemetry\n",
"\n",
"strands_telemetry = StrandsTelemetry()\n",
"strands_telemetry.setup_otlp_exporter() # Send traces to OTLP endpoint\n",
"strands_telemetry.setup_meter(enable_otlp_exporter=True) # Setup new meter provider\n"
]
},
{
"cell_type": "markdown",
"id": "14982a12",
"metadata": {},
"source": [
"## 3. Use Strands Agents normally\n",
"\n",
"All the traces will be captured and sent to Openlayer."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "524ec2e1",
"metadata": {},
"outputs": [],
"source": [
"from strands import Agent\n",
"\n",
"agent = Agent(\n",
" model=\"us.anthropic.claude-sonnet-4-5-20250929-v1:0\",\n",
" system_prompt=\"You are a helpful AI assistant\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb181016",
"metadata": {},
"outputs": [],
"source": [
"response = agent(\"What can you help me with?\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c626153",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "bedrock-test",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}