Skip to content

Commit a025a20

Browse files
authored
Anthropic agents boilerplate (open-telemetry#4179)
* Add initial implementation of Anthropic Agents instrumentation - Introduced `opentelemetry-instrumentation-anthropic-agents` package for tracing LLM requests using the Anthropic Python SDK. - Added support for capturing request and response attributes in accordance with GenAI semantic conventions. - Included examples for both manual and zero-code instrumentation. - Created a CHANGELOG.md to document notable changes. - Added LICENSE and README files for package details and usage instructions. This commit lays the groundwork for enhanced observability in applications utilizing Anthropic's capabilities. * Enhance instrumentation for Anthropic Agents - Added support for the `opentelemetry-instrumentation-anthropic-agents` package, enabling tracing of requests made through the Claude Agent SDK. - Updated `pyproject.toml` and `tox.ini` to include new test environments and dependencies for the Anthropic Agents instrumentation. - Modified GitHub workflows to incorporate linting and testing for the new instrumentation. - Improved documentation in README files and examples to reflect changes in usage and setup. - Introduced new examples demonstrating both manual and zero-code instrumentation approaches. This commit strengthens observability for applications utilizing Claude Agents, ensuring comprehensive tracing and logging capabilities. * Remove outdated entries from CHANGELOG.md for Anthropic Agents instrumentation, streamlining the document to reflect current features and improvements. * Update Anthropic Agents instrumentation to use Claude Agent SDK - Changed dependency from `anthropic >= 0.16.0` to `claude-agent-sdk >= 0.1.14` in `README.md`, `pyproject.toml`, and related files. - Refactored `AnthropicAgentsInstrumentor` to align with the new SDK, including updates to initialization and logging. - Removed unused utility functions and cleaned up test configurations to reflect the new dependency. - Updated tests to ensure compatibility with the Claude Agent SDK. This commit enhances the instrumentation for applications using the Claude Agent SDK, ensuring accurate tracing and logging capabilities. * Update Python version requirements and clean up workflows for Anthropic Agents instrumentation - Updated `tox.ini` and `pyproject.toml` to require Python 3.10 or higher, removing support for Python 3.9. - Cleaned up GitHub workflows by removing outdated test jobs for Python 3.9 and adding new jobs for Python 3.10. - Updated `README.md` to reflect the new dependency on `claude-agent-sdk` and removed references to the old SDK. - Made minor code cleanups in example scripts and test files to improve readability. These changes ensure compatibility with the latest Python versions and streamline the testing process for the Anthropic Agents instrumentation. * Add Anirudha as a component owner for Anthropic instrumentation. * fixing precommit errors. * Update version comment in `version.py` to indicate future stable release * Refactor imports in `__init__.py` for Anthropic Agents instrumentation. * regenerate uv.lock file. * Update uv.lock to standardize package source URLs with trailing slashes * Rename instrumentation for Anthropic Agents to Claude Agent SDK, updating references in configuration files, workflows, and documentation. Add new files for the Claude Agent SDK instrumentation, including README, examples, and changelog. Ensure proper setup for testing and linting in CI/CD workflows. * Update release documentation and workflows to include new instrumentation for Anthropic and Claude Agent SDK. * Add Mike Goldsmith as a component owner for Anthropic and Claude Agent SDK instrumentation * Revert "Merge remote-tracking branch 'upstream/main' into feat/anthropic-agents-boilerplate" This reverts commit 7ed01ec, reversing changes made to 7e83cd7. * Reapply "Merge remote-tracking branch 'upstream/main' into feat/anthropic-agents-boilerplate" This reverts commit 7714e3c. * Update Python version in workflows and adjust dependencies in uv.lock. * Fix source URLs in uv.lock to ensure proper registry formatting.
1 parent f189a1f commit a025a20

35 files changed

+2165
-2223
lines changed

.github/component_owners.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,10 @@ components:
5757

5858
instrumentation-genai/opentelemetry-instrumentation-anthropic:
5959
- vasantteja
60+
- anirudha
61+
- MikeGoldsmith
62+
63+
instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk:
64+
- vasantteja
65+
- anirudha
66+
- MikeGoldsmith

.github/workflows/lint_0.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,25 @@ jobs:
127127
- name: Run tests
128128
run: tox -e lint-instrumentation-anthropic
129129

130+
lint-instrumentation-claude-agent-sdk:
131+
name: instrumentation-claude-agent-sdk
132+
runs-on: ubuntu-latest
133+
timeout-minutes: 30
134+
steps:
135+
- name: Checkout repo @ SHA - ${{ github.sha }}
136+
uses: actions/checkout@v4
137+
138+
- name: Set up Python 3.14
139+
uses: actions/setup-python@v5
140+
with:
141+
python-version: "3.14"
142+
143+
- name: Install tox
144+
run: pip install tox-uv
145+
146+
- name: Run tests
147+
run: tox -e lint-instrumentation-claude-agent-sdk
148+
130149
lint-resource-detector-containerid:
131150
name: resource-detector-containerid
132151
runs-on: ubuntu-latest

.github/workflows/package-prepare-patch-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
- opentelemetry-instrumentation-openai-v2
1212
- opentelemetry-instrumentation-openai-agents-v2
1313
- opentelemetry-instrumentation-vertexai
14+
- opentelemetry-instrumentation-anthropic
15+
- opentelemetry-instrumentation-claude-agent-sdk
1416
- opentelemetry-instrumentation-google-genai
1517
- opentelemetry-util-genai
1618
description: 'Package to be released'

.github/workflows/package-prepare-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
- opentelemetry-instrumentation-openai-v2
1212
- opentelemetry-instrumentation-openai-agents-v2
1313
- opentelemetry-instrumentation-vertexai
14+
- opentelemetry-instrumentation-anthropic
15+
- opentelemetry-instrumentation-claude-agent-sdk
1416
- opentelemetry-instrumentation-google-genai
1517
- opentelemetry-util-genai
1618
description: 'Package to be released'

.github/workflows/package-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
- opentelemetry-instrumentation-openai-v2
1212
- opentelemetry-instrumentation-openai-agents-v2
1313
- opentelemetry-instrumentation-vertexai
14+
- opentelemetry-instrumentation-anthropic
15+
- opentelemetry-instrumentation-claude-agent-sdk
1416
- opentelemetry-instrumentation-google-genai
1517
- opentelemetry-util-genai
1618
description: 'Package to be released'

.github/workflows/test_0.yml

Lines changed: 152 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,158 @@ jobs:
11721172
- name: Run tests
11731173
run: tox -e py314-test-instrumentation-anthropic-latest -- -ra
11741174

1175+
py310-test-instrumentation-claude-agent-sdk-oldest_ubuntu-latest:
1176+
name: instrumentation-claude-agent-sdk-oldest 3.10 Ubuntu
1177+
runs-on: ubuntu-latest
1178+
timeout-minutes: 30
1179+
steps:
1180+
- name: Checkout repo @ SHA - ${{ github.sha }}
1181+
uses: actions/checkout@v4
1182+
1183+
- name: Set up Python 3.10
1184+
uses: actions/setup-python@v5
1185+
with:
1186+
python-version: "3.10"
1187+
1188+
- name: Install tox
1189+
run: pip install tox-uv
1190+
1191+
- name: Run tests
1192+
run: tox -e py310-test-instrumentation-claude-agent-sdk-oldest -- -ra
1193+
1194+
py310-test-instrumentation-claude-agent-sdk-latest_ubuntu-latest:
1195+
name: instrumentation-claude-agent-sdk-latest 3.10 Ubuntu
1196+
runs-on: ubuntu-latest
1197+
timeout-minutes: 30
1198+
steps:
1199+
- name: Checkout repo @ SHA - ${{ github.sha }}
1200+
uses: actions/checkout@v4
1201+
1202+
- name: Set up Python 3.10
1203+
uses: actions/setup-python@v5
1204+
with:
1205+
python-version: "3.10"
1206+
1207+
- name: Install tox
1208+
run: pip install tox-uv
1209+
1210+
- name: Run tests
1211+
run: tox -e py310-test-instrumentation-claude-agent-sdk-latest -- -ra
1212+
1213+
py311-test-instrumentation-claude-agent-sdk-oldest_ubuntu-latest:
1214+
name: instrumentation-claude-agent-sdk-oldest 3.11 Ubuntu
1215+
runs-on: ubuntu-latest
1216+
timeout-minutes: 30
1217+
steps:
1218+
- name: Checkout repo @ SHA - ${{ github.sha }}
1219+
uses: actions/checkout@v4
1220+
1221+
- name: Set up Python 3.11
1222+
uses: actions/setup-python@v5
1223+
with:
1224+
python-version: "3.11"
1225+
1226+
- name: Install tox
1227+
run: pip install tox-uv
1228+
1229+
- name: Run tests
1230+
run: tox -e py311-test-instrumentation-claude-agent-sdk-oldest -- -ra
1231+
1232+
py311-test-instrumentation-claude-agent-sdk-latest_ubuntu-latest:
1233+
name: instrumentation-claude-agent-sdk-latest 3.11 Ubuntu
1234+
runs-on: ubuntu-latest
1235+
timeout-minutes: 30
1236+
steps:
1237+
- name: Checkout repo @ SHA - ${{ github.sha }}
1238+
uses: actions/checkout@v4
1239+
1240+
- name: Set up Python 3.11
1241+
uses: actions/setup-python@v5
1242+
with:
1243+
python-version: "3.11"
1244+
1245+
- name: Install tox
1246+
run: pip install tox-uv
1247+
1248+
- name: Run tests
1249+
run: tox -e py311-test-instrumentation-claude-agent-sdk-latest -- -ra
1250+
1251+
py312-test-instrumentation-claude-agent-sdk-oldest_ubuntu-latest:
1252+
name: instrumentation-claude-agent-sdk-oldest 3.12 Ubuntu
1253+
runs-on: ubuntu-latest
1254+
timeout-minutes: 30
1255+
steps:
1256+
- name: Checkout repo @ SHA - ${{ github.sha }}
1257+
uses: actions/checkout@v4
1258+
1259+
- name: Set up Python 3.12
1260+
uses: actions/setup-python@v5
1261+
with:
1262+
python-version: "3.12"
1263+
1264+
- name: Install tox
1265+
run: pip install tox-uv
1266+
1267+
- name: Run tests
1268+
run: tox -e py312-test-instrumentation-claude-agent-sdk-oldest -- -ra
1269+
1270+
py312-test-instrumentation-claude-agent-sdk-latest_ubuntu-latest:
1271+
name: instrumentation-claude-agent-sdk-latest 3.12 Ubuntu
1272+
runs-on: ubuntu-latest
1273+
timeout-minutes: 30
1274+
steps:
1275+
- name: Checkout repo @ SHA - ${{ github.sha }}
1276+
uses: actions/checkout@v4
1277+
1278+
- name: Set up Python 3.12
1279+
uses: actions/setup-python@v5
1280+
with:
1281+
python-version: "3.12"
1282+
1283+
- name: Install tox
1284+
run: pip install tox-uv
1285+
1286+
- name: Run tests
1287+
run: tox -e py312-test-instrumentation-claude-agent-sdk-latest -- -ra
1288+
1289+
py313-test-instrumentation-claude-agent-sdk-oldest_ubuntu-latest:
1290+
name: instrumentation-claude-agent-sdk-oldest 3.13 Ubuntu
1291+
runs-on: ubuntu-latest
1292+
timeout-minutes: 30
1293+
steps:
1294+
- name: Checkout repo @ SHA - ${{ github.sha }}
1295+
uses: actions/checkout@v4
1296+
1297+
- name: Set up Python 3.13
1298+
uses: actions/setup-python@v5
1299+
with:
1300+
python-version: "3.13"
1301+
1302+
- name: Install tox
1303+
run: pip install tox-uv
1304+
1305+
- name: Run tests
1306+
run: tox -e py313-test-instrumentation-claude-agent-sdk-oldest -- -ra
1307+
1308+
py313-test-instrumentation-claude-agent-sdk-latest_ubuntu-latest:
1309+
name: instrumentation-claude-agent-sdk-latest 3.13 Ubuntu
1310+
runs-on: ubuntu-latest
1311+
timeout-minutes: 30
1312+
steps:
1313+
- name: Checkout repo @ SHA - ${{ github.sha }}
1314+
uses: actions/checkout@v4
1315+
1316+
- name: Set up Python 3.13
1317+
uses: actions/setup-python@v5
1318+
with:
1319+
python-version: "3.13"
1320+
1321+
- name: Install tox
1322+
run: pip install tox-uv
1323+
1324+
- name: Run tests
1325+
run: tox -e py313-test-instrumentation-claude-agent-sdk-latest -- -ra
1326+
11751327
py39-test-resource-detector-containerid_ubuntu-latest:
11761328
name: resource-detector-containerid 3.9 Ubuntu
11771329
runs-on: ubuntu-latest
@@ -4629,155 +4781,3 @@ jobs:
46294781

46304782
- name: Run tests
46314783
run: tox -e py314-test-instrumentation-fastapi -- -ra
4632-
4633-
pypy3-test-instrumentation-fastapi_ubuntu-latest:
4634-
name: instrumentation-fastapi pypy-3.9 Ubuntu
4635-
runs-on: ubuntu-latest
4636-
timeout-minutes: 30
4637-
steps:
4638-
- name: Checkout repo @ SHA - ${{ github.sha }}
4639-
uses: actions/checkout@v4
4640-
4641-
- name: Set up Python pypy-3.9
4642-
uses: actions/setup-python@v5
4643-
with:
4644-
python-version: "pypy-3.9"
4645-
4646-
- name: Install tox
4647-
run: pip install tox-uv
4648-
4649-
- name: Run tests
4650-
run: tox -e pypy3-test-instrumentation-fastapi -- -ra
4651-
4652-
py39-test-instrumentation-flask-0_ubuntu-latest:
4653-
name: instrumentation-flask-0 3.9 Ubuntu
4654-
runs-on: ubuntu-latest
4655-
timeout-minutes: 30
4656-
steps:
4657-
- name: Checkout repo @ SHA - ${{ github.sha }}
4658-
uses: actions/checkout@v4
4659-
4660-
- name: Set up Python 3.9
4661-
uses: actions/setup-python@v5
4662-
with:
4663-
python-version: "3.9"
4664-
4665-
- name: Install tox
4666-
run: pip install tox-uv
4667-
4668-
- name: Run tests
4669-
run: tox -e py39-test-instrumentation-flask-0 -- -ra
4670-
4671-
py39-test-instrumentation-flask-1_ubuntu-latest:
4672-
name: instrumentation-flask-1 3.9 Ubuntu
4673-
runs-on: ubuntu-latest
4674-
timeout-minutes: 30
4675-
steps:
4676-
- name: Checkout repo @ SHA - ${{ github.sha }}
4677-
uses: actions/checkout@v4
4678-
4679-
- name: Set up Python 3.9
4680-
uses: actions/setup-python@v5
4681-
with:
4682-
python-version: "3.9"
4683-
4684-
- name: Install tox
4685-
run: pip install tox-uv
4686-
4687-
- name: Run tests
4688-
run: tox -e py39-test-instrumentation-flask-1 -- -ra
4689-
4690-
py39-test-instrumentation-flask-2_ubuntu-latest:
4691-
name: instrumentation-flask-2 3.9 Ubuntu
4692-
runs-on: ubuntu-latest
4693-
timeout-minutes: 30
4694-
steps:
4695-
- name: Checkout repo @ SHA - ${{ github.sha }}
4696-
uses: actions/checkout@v4
4697-
4698-
- name: Set up Python 3.9
4699-
uses: actions/setup-python@v5
4700-
with:
4701-
python-version: "3.9"
4702-
4703-
- name: Install tox
4704-
run: pip install tox-uv
4705-
4706-
- name: Run tests
4707-
run: tox -e py39-test-instrumentation-flask-2 -- -ra
4708-
4709-
py39-test-instrumentation-flask-3_ubuntu-latest:
4710-
name: instrumentation-flask-3 3.9 Ubuntu
4711-
runs-on: ubuntu-latest
4712-
timeout-minutes: 30
4713-
steps:
4714-
- name: Checkout repo @ SHA - ${{ github.sha }}
4715-
uses: actions/checkout@v4
4716-
4717-
- name: Set up Python 3.9
4718-
uses: actions/setup-python@v5
4719-
with:
4720-
python-version: "3.9"
4721-
4722-
- name: Install tox
4723-
run: pip install tox-uv
4724-
4725-
- name: Run tests
4726-
run: tox -e py39-test-instrumentation-flask-3 -- -ra
4727-
4728-
py310-test-instrumentation-flask-0_ubuntu-latest:
4729-
name: instrumentation-flask-0 3.10 Ubuntu
4730-
runs-on: ubuntu-latest
4731-
timeout-minutes: 30
4732-
steps:
4733-
- name: Checkout repo @ SHA - ${{ github.sha }}
4734-
uses: actions/checkout@v4
4735-
4736-
- name: Set up Python 3.10
4737-
uses: actions/setup-python@v5
4738-
with:
4739-
python-version: "3.10"
4740-
4741-
- name: Install tox
4742-
run: pip install tox-uv
4743-
4744-
- name: Run tests
4745-
run: tox -e py310-test-instrumentation-flask-0 -- -ra
4746-
4747-
py310-test-instrumentation-flask-1_ubuntu-latest:
4748-
name: instrumentation-flask-1 3.10 Ubuntu
4749-
runs-on: ubuntu-latest
4750-
timeout-minutes: 30
4751-
steps:
4752-
- name: Checkout repo @ SHA - ${{ github.sha }}
4753-
uses: actions/checkout@v4
4754-
4755-
- name: Set up Python 3.10
4756-
uses: actions/setup-python@v5
4757-
with:
4758-
python-version: "3.10"
4759-
4760-
- name: Install tox
4761-
run: pip install tox-uv
4762-
4763-
- name: Run tests
4764-
run: tox -e py310-test-instrumentation-flask-1 -- -ra
4765-
4766-
py310-test-instrumentation-flask-2_ubuntu-latest:
4767-
name: instrumentation-flask-2 3.10 Ubuntu
4768-
runs-on: ubuntu-latest
4769-
timeout-minutes: 30
4770-
steps:
4771-
- name: Checkout repo @ SHA - ${{ github.sha }}
4772-
uses: actions/checkout@v4
4773-
4774-
- name: Set up Python 3.10
4775-
uses: actions/setup-python@v5
4776-
with:
4777-
python-version: "3.10"
4778-
4779-
- name: Install tox
4780-
run: pip install tox-uv
4781-
4782-
- name: Run tests
4783-
run: tox -e py310-test-instrumentation-flask-2 -- -ra

0 commit comments

Comments
 (0)