From 18a808285438c46c36bf63db7a62c0278b3c1ff9 Mon Sep 17 00:00:00 2001 From: Gustavo Cid Date: Mon, 15 Dec 2025 15:09:34 -0300 Subject: [PATCH] docs(closes OPEN-8401): strands Agents integration --- .../strands_agents_tracing.ipynb | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 examples/tracing/strands-agents/strands_agents_tracing.ipynb diff --git a/examples/tracing/strands-agents/strands_agents_tracing.ipynb b/examples/tracing/strands-agents/strands_agents_tracing.ipynb new file mode 100644 index 00000000..5e614ac9 --- /dev/null +++ b/examples/tracing/strands-agents/strands_agents_tracing.ipynb @@ -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", + "# Strands Agents quickstart\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 +}