* 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 7ed01ecb2d, reversing
changes made to 7e83cd7d74.
* Reapply "Merge remote-tracking branch 'upstream/main' into feat/anthropic-agents-boilerplate"
This reverts commit 7714e3c544.
* Update Python version in workflows and adjust dependencies in uv.lock.
* Fix source URLs in uv.lock to ensure proper registry formatting.
* add gen_ai.tool_definitions to completion hook
* hash tool defintions
* Update CHANGELOG
* make tool.defintions optional in on_completion
* fix lint errors
* add gen_ai.tool_definitions to completion hook
* hash tool defintions
* fix CompetionHook docstring
* fix lint test
* add gen_ai.tool_definitions to completion hook
* hash tool defintions
* Update CHANGELOG
* align tool.defintions with JSON schema
* fix tests
* fix ruff
* fix unexpected indent
* use local changes from util/opentelemetry-util-genai
* fix ruff
* add gen_ai.tool_definitions to completion hook
* re-add changes lost during merge
* put tool.defintions in the telemetry by default and the params behind the flag
* fix: Too many local variables
* address comments
* Add comments to udpate of util-genai version after release
---------
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* update invocation span to have kind SERVER and have name equal to the function name
* update Lambda invocation span name and kind
* add type checking check
* move changelog entry to 'Breaking changes'
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* cassandra: use _instruments_any instead of _instruments for driver deps
The cassandra instrumentation listed both cassandra-driver and
scylla-driver in _instruments, which requires ALL listed packages to be
installed. Since users install one OR the other (they are alternative
drivers for the same API), this should use _instruments_any so that
having either driver installed is sufficient.
This follows the same pattern already used by psycopg2 and kafka-python
instrumentations, introduced in #3610.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix ci
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* fix uv.lock
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
---------
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: emdneto <9735060+emdneto@users.noreply.github.com>
* fix instrument of typed psycopg sql
The instrumentation is not working when using [typed `SQL`](https://www.psycopg.org/psycopg3/docs/api/sql.html) from psycopg (only when using the `Composed` type, that is returned when the query is formated).
```python
from psycopg.sql import SQL
query = SQL("SELECT * FROM test")
```
This fixes it by checking the `Composable` base class instead of the more restricted `Composed`.
* add changelog
* fix tests for python 3.9
using an identifier requires a real connection, I just replaced it since we only want to test with a composed.
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
StreamWrapper did not proxy unknown attributes like .headers to the
underlying stream, causing AttributeError when using
with_raw_response.create(stream=True).
Add __getattr__ to delegate attribute lookups to self.stream.
Fixes#4113
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* fastapi: use test_base to fetch metrics for assertions or filter locally
* Pass scope
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* feat propagate custom genai generate_content attributes to logs in addition to spans
* Put the extra attributes on logs that follow the old semanting convention as well
* Use dict[str, AttributeValue] instead of dict[str, Any]
* Revert "Put the extra attributes on logs that follow the old semanting convention as well"
This reverts commit 72a5c99cad.
* Update CHANGELOG.md
* Fix lint
---------
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* opentelemetry-instrumentation-logging: don't add out of spec attributes by default
Add span context attributes to logging module LogRecord only if the instrumentation
has been configured to do so via set_logging_format argument or OTEL_PYTHON_LOG_CORRELATION
environment variable.
* Add changelog
* Update doc and cleanup tests
* Reduce diff
* Add missing test