From a4fc0cf5da88fcb7faf5198327fe3891dc550711 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 1 Oct 2025 18:19:05 -0700 Subject: [PATCH] docs: add opik to traces examples --- .../observability-evaluation/traces.md | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/user-guide/observability-evaluation/traces.md b/docs/user-guide/observability-evaluation/traces.md index d812238a..58f826bb 100644 --- a/docs/user-guide/observability-evaluation/traces.md +++ b/docs/user-guide/observability-evaluation/traces.md @@ -389,8 +389,51 @@ print(response) # Each interaction creates a complete trace that can be visualized in your tracing tool ``` +## Sending traces to Opik + +[Opik](https://www.comet.com/opik/) is Comet's observability, evaluation, and optimization platform for LLM and agent applications. Because Strands is already instrumented with OpenTelemetry, you only need to point the OTLP exporter at the Opik collector to gain: + +- Rich span visualizations that preserve the Strands agent → cycle → tool hierarchy +- Automatic token, cost, and latency tracking for every LLM call handled by Strands Telemetry +- Error analytics and thread grouping so multi-turn conversations remain easy to debug + +### Configure environment variables + +Set the OTLP endpoint and headers that correspond to your Opik deployment before you start your Strands application: + +```bash wordWrap +# Opik Cloud +export OTEL_EXPORTER_OTLP_ENDPOINT=https://www.comet.com/opik/api/v1/private/otel +export OTEL_EXPORTER_OTLP_HEADERS='Authorization=,Comet-Workspace=,projectName=' + +# Opik Enterprise +export OTEL_EXPORTER_OTLP_ENDPOINT=https:///opik/api/v1/private/otel +export OTEL_EXPORTER_OTLP_HEADERS='Authorization=,Comet-Workspace=,projectName=' + +# Self-hosted Opik +export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5173/api/v1/private/otel +export OTEL_EXPORTER_OTLP_HEADERS='projectName=' +``` + +If you prefer to set headers inside your code, you can pass them to `setup_otlp_exporter`: + +```python +from strands.telemetry import StrandsTelemetry + +StrandsTelemetry().setup_otlp_exporter( + endpoint="https://www.comet.com/opik/api/v1/private/otel", + headers={ + "Authorization": "", + "Comet-Workspace": "default", + "projectName": "strands-demo", + }, +) +``` + +Once configured, launch your agents as usual. Each interaction will appear in Opik's trace explorer with the same nested structure shown earlier in this guide. + ## Sending traces to CloudWatch X-ray There are several ways to send traces, metrics, and logs to CloudWatch. Please visit the following pages for more details and configurations: 1. [AWS Distro for OpenTelemetry Collector](https://aws-otel.github.io/docs/getting-started/x-ray#configuring-the-aws-x-ray-exporter) 2. [AWS CloudWatch OpenTelemetry User Guide](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-OpenTelemetry-Sections.html) - - Please ensure Transaction Search is enabled in CloudWatch. \ No newline at end of file + - Please ensure Transaction Search is enabled in CloudWatch.