{"id":48391555,"url":"https://github.com/langchain-samples/strands-otel-tracing-example","last_synced_at":"2026-04-06T00:15:08.732Z","repository":{"id":346654510,"uuid":"1077700043","full_name":"langchain-samples/strands-otel-tracing-example","owner":"langchain-samples","description":"LangSmith tracing example for strands agent ","archived":false,"fork":false,"pushed_at":"2026-03-25T17:29:14.000Z","size":193,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-26T01:44:51.370Z","etag":null,"topics":["intermediate","langsmith","observability","strands"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/langchain-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-16T16:01:10.000Z","updated_at":"2026-03-25T17:29:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/langchain-samples/strands-otel-tracing-example","commit_stats":null,"previous_names":["langchain-samples/strands-otel-tracing-example"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/langchain-samples/strands-otel-tracing-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fstrands-otel-tracing-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fstrands-otel-tracing-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fstrands-otel-tracing-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fstrands-otel-tracing-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/langchain-samples","download_url":"https://codeload.github.com/langchain-samples/strands-otel-tracing-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fstrands-otel-tracing-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31454268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["intermediate","langsmith","observability","strands"],"created_at":"2026-04-06T00:15:03.533Z","updated_at":"2026-04-06T00:15:08.725Z","avatar_url":"https://github.com/langchain-samples.png","language":"Python","readme":"# Tracing for Strands Agents\n\nThis project demonstrates how to instrument and trace an example strands agent to LangSmith using OpenTelemetry, enabling you to monitor model \u0026 agent performance, latency, and token usage.\n\n🛠 Setup\nClone the repo\n\n### Clone the repo\n\n```\ngit clone https://github.com/langchain-ai/strands-otel-tracing-example\n```\n\n### Create an environment variables file\n\n```\n$ cd strands-example\n# Copy the .env.example file to .env\ncp .env.example .env\n```\n\nFill in fields such as OTel endpoint, headers (project and API key), and AWS credentials\n\n### Package Installation\n\nEnsure you have a recent version of `uv` installed\n\n```\n$ uv sync\n```\n\n### Run the agent\n\n```\n$ uv run otel_strands_share.py\n```\n\nYou can then see an example [trace](https://smith.langchain.com/public/bd48a376-0006-401a-9f6f-d71bfa31e10c/r) in the LangSmith project specified!\n\n### Using in your own project\n\nCopy `langsmith_exporter.py` into your project, then call `setup_langsmith_telemetry()` before creating your agent:\n\n```python\nfrom langsmith_exporter import setup_langsmith_telemetry\nfrom strands import Agent\n\nsetup_langsmith_telemetry()\n```\n\nThis replaces the standard `StrandsTelemetry().setup_otlp_exporter()` call. It wraps the OTLP exporter with a transformation layer that:\n\n- **Standardizes message attributes** — Strands emits messages as span events, but the GenAI semantic conventions specify them as `gen_ai.prompt` / `gen_ai.completion` span attributes. The exporter normalizes to the expected format.\n- **Standardizes content blocks** — Converts Bedrock/Converse-shaped blocks (`{\"text\": \"...\"}`, `{\"toolUse\": {...}}`) into typed blocks (`{\"type\": \"text\", \"text\": \"...\"}`, `{\"type\": \"tool_use\", ...}`).\n- **Maps run types** — Sets `langsmith.span.kind` based on `gen_ai.operation.name` so spans render as the correct type in LangSmith (`chain` for agent invocations, `llm` for model calls, `tool` for tool executions).\n\nThe exporter reads endpoint and auth configuration from the standard `OTEL_EXPORTER_OTLP_*` environment variables in this repo's `.env.example` file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-samples%2Fstrands-otel-tracing-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flangchain-samples%2Fstrands-otel-tracing-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-samples%2Fstrands-otel-tracing-example/lists"}