* Move logging integrations into auto-instrumentation
* opentelemetry-instrumentation-logging: move the sdk logging handler here
And hook it up via entry point
* Add header and future annotations import
* Rename entry point group to opentelemetry_logging_integrations
* Consider setting up the LoggingHandler as a normal instrumentation
* Fix typo
* Add missing import
* Copy handler tests from core
* More work towards green tests
* Cleanup properly after loggingHandler tests
* Quite hard to expect a mock to setup the handler
* Call removehandler also on local loggers
No change in practice
* Fix wrong noop test
* Move to our own env var for controlling autoinstrumentation
* Copy handler benchmark from sdk
* Document the new environment variables
* Add changelog
* Please pylint
* Added warning about coexistence with sdk code
* Reword a bit
* Assert that the LoggingHandler has not been setup in uninstrumented test
* Add manual handling of auto instrumentation and code attributes logging
* Update instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/constants.py
* Apply suggestions from code review
Co-authored-by: Pablo Collins <pablo.collins@gmail.com>
* Apply more Pablo feedback
---------
Co-authored-by: Pablo Collins <pablo.collins@gmail.com>
* asyncio: fix environment variables not in docs
Fix the docstrings in environment_variables.py so they are correctly
picked up by Sphinx autodoc for Read the Docs.
Previously the docstrings were placed above the variable assignments,
which Sphinx cannot parse. Moved them below and added the
required '.. envvar::' directives, consistent with how other
packages (e.g. opentelemetry-instrumentation) document their
environment variables.
Fixes#4256
* Fix typo from 'determines' to 'determine'
* Apply suggestion from @xrmx
* asyncio: move environment_variables docs to __init__ module docstring for sphinx
* asyncio: keep envvar docs in environment_variables.py with module-level docstring
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
The openai-v2 examples predate (2024) the Jan 2025 decouple
(f3b9e6ec96b7cc3717d5c8b529da7a8923810973 in core) of the log machinery setup from
the LoggingHandler setup. So unless I'm missing something and you
really want to see OpenTelemetry logs shipped from Python logging module
usage in these genai examples I think we can drop these.
We're moving the logging handler from the sdk to the opentelemetry-instrumentation-logging and
deprecating that environment variable.
* gen-requirements: stay with virtualenv < 21
No idea what's going on but looks like hatch / hatchling has issues with
latest virtualenv 21:
Environment `hatch-build` is incompatible: module 'virtualenv.discovery.builtin' has no attribute 'propose_interpreters'
* Update gen-requirements.txt
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
---------
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
* 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>