Commit Graph

2849 Commits

Author SHA1 Message Date
Teja
ff7f60ef80 feat: Add sync streaming support for Anthropic instrumentation (#4155)
* Add sync streaming support for Anthropic instrumentation

- Add support for Messages.create(stream=True) with StreamWrapper
- Add support for Messages.stream() with MessageStreamManagerWrapper
- Add MessageWrapper for non-streaming response telemetry
- Rename MessageCreateParams to MessageRequestParams
- Add comprehensive tests for sync streaming functionality

* Add changelog entry for sync streaming support

* Fix type checking errors with type: ignore comments

- Add type: ignore[arg-type] for Union type narrowing in messages_create
- Add type: ignore[return-value] for wrapper return types
- Add type: ignore[return-value] for __exit__ returning None

* Refactor Anthropic instrumentation to improve usage tracking and error handling

- Introduce constants for provider name and cache token attributes.
- Normalize stop reasons and aggregate cache token fields in MessageWrapper and StreamWrapper.
- Enhance tests to validate input token aggregation and stop reason normalization.
- Update cassettes for new request and response structures in streaming scenarios.

* Refactor utility functions and test cases for improved readability and consistency

- Simplify constant definitions and normalize function calls in utils.py.
- Enhance test cases by removing unnecessary line breaks and improving formatting.
- Ensure consistent usage of type hints and comments in test functions.

* Refactor argument handling in assert_span_attributes function

- Update the pylint directive to disable too-many-arguments warning for better clarity.
- Maintain consistency in function signature and improve code readability.

* Enhance tests for streaming message handling in Anthropic instrumentation

- Update test cases to validate streaming behavior with various parameters, including token usage and stop reasons.
- Introduce new cassettes for different scenarios, ensuring comprehensive coverage of streaming interactions.
- Refactor existing tests for clarity and consistency in structure and assertions.

* Update test_sync_messages.py to disable pylint warning for too-many-locals in test_stream_wrapper_finalize_idempotent function

* Enhance StreamWrapper and MessageStreamManagerWrapper for idempotent finalization

- Refactor finalization logic in StreamWrapper and MessageStreamManagerWrapper to ensure idempotent behavior during context exit.
- Introduce new methods for successful and error finalization, improving clarity and reducing code duplication.
- Add tests to validate double exit idempotency in streaming scenarios, ensuring only one span is emitted.
- Update cassettes to reflect new request and response structures for streaming interactions.

* Enhance Anthropic instrumentation to support content capture

- Added logger_provider to TelemetryHandler for improved logging capabilities.
- Implemented content capture logic in messages_create and messages_stream functions, allowing for the extraction of input messages and system instructions.
- Introduced utility functions for content conversion and message handling in utils.py.
- Updated tests to validate content capture functionality for both synchronous and streaming message creation.
- Added new cassettes to reflect the changes in request and response structures for content capture scenarios.

* Enhance tests for sync message creation in Anthropic instrumentation

- Added checks for the presence of 'tools' and 'thinking' parameters in the installed anthropic SDK.
- Updated test cases to skip if the SDK version does not support these parameters, ensuring compatibility with older versions.
- Improved test robustness by dynamically determining parameter support.

* Remove sensitive 'anthropic-organization-id' headers from test cassettes and update header scrubbing logic in tests. This enhances security by ensuring sensitive information is not recorded in test artifacts.

* Refactor tests for sync message handling in Anthropic instrumentation

- Simplified detection of 'tools' and 'thinking' parameters by directly accessing the _Messages class.
- Improved readability of test cases by formatting input message loading.
- Enhanced test function signatures for better clarity and maintainability.

* Refactor utils.py for improved type safety and clarity

- Added type casting for dictionary access to enhance type safety.
- Simplified content block conversion logic to improve readability and maintainability.
- Updated test cases to ensure consistent handling of content types and structures.

* Enhance Anthropic instrumentation tests for EVENT_ONLY content capture

- Introduced a new fixture to instrument Anthropic with EVENT_ONLY content capture mode.
- Added tests to verify that content is not captured in span attributes while ensuring log events are emitted correctly.
- Updated cassettes to reflect new request and response structures for EVENT_ONLY scenarios.
- Enhanced existing tests to cover various content capture scenarios, including streaming and tool usage.

* Refactor assertion in sync messages test for clarity

- Simplified the assertion statement in the test_sync_messages_create_event_only_no_content_in_span function to improve readability.

* Refactor content capture logic and enhance streaming tests for Anthropic instrumentation.

* unsetting the model.

* Remove instrumentation for Messages.stream() and refactor related code. Introduced MessageWrapper and StreamWrapper classes for telemetry handling. Updated tests to reflect changes in instrumentation behavior.

* Refactor Anthropic instrumentation: reorganize imports, enhance utility functions, and update wrapper classes for better clarity and maintainability. Removed unused code and improved type safety in utility functions. Updated tests to reflect changes in the instrumentation behavior.

* Add message extractors for Anthropic instrumentation.

* Refactor message extractors in Anthropic instrumentation: reorganize imports and streamline finish reason normalization for improved clarity and maintainability.

* Update test cassettes for Anthropic instrumentation: streamline request and response structures, enhance error handling scenarios, and ensure consistency in message formats across various test cases. Removed outdated data and improved clarity in test interactions.

* Enhance Anthropic instrumentation: update MessageWrapper and StreamWrapper to include content capture logic, improve type safety with explicit casting, and streamline test cases for better clarity. Added new test for streaming response attributes and refined existing tests to ensure consistency in message handling.

* Update test cassettes for Anthropic instrumentation: modify message IDs, timestamps, and token usage across various test cases. Refine content capture logic and ensure consistency in message formats, including adjustments to event data and headers for improved clarity and accuracy.

* Rename StreamWrapper to MessagesStreamWrapper and update references in code and tests

* Refactor type annotations in message extractors and wrappers for improved type safety. Replace 'Any' with 'object' in several function signatures and class attributes. Introduce logging for error handling in MessagesStreamWrapper to enhance instrumentation reliability.

* Enhance type annotations in message extractors and patch for improved clarity and safety. Update function signatures to use specific types instead of 'object', including changes to parameters in extract_params, get_input_messages, and get_system_instruction. Refactor messages_create to ensure correct type handling for streaming and non-streaming responses. Additionally, streamline message handling in MessagesStreamWrapper for better performance and reliability.

* Enhance type safety and error handling in message processing. Update function signatures in `messages_extractors.py` and `wrappers.py` to include specific types, improving clarity and reliability. Introduce handling for `None` values in `get_input_messages` and `get_system_instruction`. Refactor `MessagesStreamWrapper` to better manage usage updates and ensure correct type handling for streaming responses. Add new test cases for aggregating cache tokens and handling streaming errors.

* Refactor assertions in test_sync_messages.py for improved readability. Simplify assertion statements by removing unnecessary parentheses, enhancing code clarity in cache token tests.

* enforce strong typing system.

* Update anthropic dependency version to 0.51.0 in pyproject.toml and requirements.oldest.txt for compatibility improvements.

* Refactor usage token extraction to utilize a new UsageTokens dataclass for improved clarity and type safety. Update extract_usage_tokens function to return UsageTokens instead of a tuple, and adjust related invocations in MessageWrapper and MessagesStreamWrapper accordingly.

* Update anthropic dependency version in uv.lock to 0.51.0 for compatibility improvements.

* Add tests for should_capture_content function in test_events_options.py.

* Enhance Anthropic instrumentation by adding logging support and refining type hints in messages_create function. Update test cassettes for improved accuracy and consistency in response data.

* Refactor content capturing utility function to clarify its purpose in experimental mode. Update related tests to reflect the new function name and ensure accurate assertions for content capturing behavior.

* Refactor import statements in patch.py for improved readability and organization.

---------

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
2026-03-09 14:34:04 +00:00
Riccardo Magliocchetti
578373a91f Cleanup docker tests (#4311)
* Remove unneded packages from docker tests

* Bump some dependencies to avoid warning on deprecated crypto algos

* Remove instrumentations that are not tested in docker-tests
2026-03-09 09:56:46 +00:00
Nagkumar Arkalgud
03891c0aaa fix(openai-agents): align AgentSpanData stubs and span processor with real SDK (#4229) 2026-03-06 15:22:32 -05:00
Mike Goldsmith
7701174242 fix(ci): eliminate SHA propagation flakiness in Core Contrib Test (#4305)
* fix(ci): eliminate SHA propagation flakiness in Core Contrib Test

Each Core Contrib Test job was doing two separate git operations for
the core repo: actions/checkout (uses GitHub internal API, always
works) and then tox installing packages via git+https:// (hits public
CDN, fails when SHA hasn't propagated yet).

Fix by setting per-package env vars (CORE_REPO_API, CORE_REPO_SDK,
CORE_REPO_SEMCONV, CORE_REPO_TEST_UTILS) in the CI workflow to point
at the already-checked-out local copy, eliminating the second network
clone entirely.

Backward compatible: when the new vars are unset (local dev), they
fall back to the existing git URL + subdirectory behavior.

Fixes #4304

Assisted-by: Claude Sonnet 4.6

* fix: restore version header dropped during rebase

Assisted-by: Claude Sonnet 4.6

* move CORE_REPO_* vars to top-level env block

Use github.workspace context instead of a shell step to set the
per-package local path env vars, as suggested in code review.

Assisted-by: Claude Sonnet 4.6
2026-03-06 15:14:30 -05:00
Emídio Neto
d7a3b18760 fix fastapi tests failure with >= 0.118.0 (#4277)
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-03-06 10:48:51 +00:00
Riccardo Magliocchetti
88e5bfc630 Add a basic http OpAMP client (#3635)
* Add a basic http OpAMP client

* Add some docs and hook it into the system

Still not building content

* Add default value of 30 seconds to heartbeat message interval

* Fix docs build

* More docs improvements

* Fix spellcheck

* Remove local workaround

* Generate workflows and add to release script

* Fix typos in opamp lint commands

* Fix requirements for pylint

* Update opamp/opentelemetry-opamp-client/pyproject.toml

* Recreate requirements

* Add missing opentelemetry-api dependency

* Fix tox test commands

Drop opentelemetry api fixed version from requirements

* Fix tox

* Add baseline of vcrpy 7.0.0

* Ignore pb2 module in pylintrc

* Bump pylint to match the version in core

* Silence pylint warnings

* Don't trace opamp client own http requests

* Permit to pass a custom transport to client

And a custom session to RequestsTransport

* Don't bump pylint after all

* Fix pylint

* Try to typecheck opamp client

* Bump version after rebase

* Fix typecheck in client

* Please pyright in strict mode

* No need for functions and methods to be private since _opamp module is already private

* Add missing protobuf package installation for typecheck

* Fix docs generation

* Fix pyright exclusion rule for proto

Missed .pyi exclusion

* Feedback

* Don't flush the queue at exit

* Log transport send exceptions

* Update example to not assume that the config is in json format

* Fix typo in exception

* Looks like it's implementers

* Add timeout to stop to forward to threads join

* Clarify doc

* Fix typo in var name

* Add support for mTLS

* Add helpers for handling of ReportFullState ServerToAgent flag

Introducing basic handling of the ReportsEffectiveConfig capability

* Remove backup file

* Rewrite opamp_proto_codegen.sh to use uv

* Make the package releasable independently

* Send full state at connection

* Add 3.14 test run

* Add changelog entry

* Add missing ReportsEffectiveConfig capability in documentation

* Start version from 0.1b0 and re-record e2e tests

* Record tests against opentelemetry-go

---------

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
2026-03-05 16:36:54 +01:00
Riccardo Magliocchetti
98cbc56d2e eachdist: add missing genai packages in independently released packages (#4295)
Namely opentelemetry-instrumentation-anthropic and
opentelemetry-instrumentation-claude-agent-sdk
2026-03-04 08:58:23 -08:00
otelbot[bot]
9247085b30 Update version to 1.41.0.dev/0.62b0.dev (#4294)
* Update version to 1.41.0.dev/0.62b0.dev

* Apply suggestions from code review

---------

Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-03-04 15:05:55 +00:00
Riccardo Magliocchetti
2ab31aa6c8 CHANGELOG: fix stale action entry (#4291) 2026-03-04 10:45:46 -03:00
Liudmila Molkova
26ae9caf85 OpenAI v2 onboard onto semantic conventions 1.37.0: chat history and other breaking changes (#3715)
* Support latest experimental conventions in openai

* format

* changelog

* lint

* lint

* update to use new test utils, fix tests

* lint

* review

* address feedback

* review

* feedback: more readable
2026-03-03 12:24:35 +01:00
Riccardo Magliocchetti
489bca37c5 Move logger handlers to opentelemetry-instrumentation-logging (#4210)
* 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>
2026-03-03 10:55:30 +01:00
Tammy Baylis
c907282d68 Fix psycopg2 (un)instrument_connection to use weakref, not mutate connection object (#4257)
* Fix psycopg2 (un)instrument_connection to use weakref, not mutate object

* Changelog

* conditional import for docs types

* Lint

* SImplify test

* Simplify

* Fix docs

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-03-03 08:35:29 +00:00
Riccardo Magliocchetti
6ae0615bb3 gen-requirements: drop virtualenv limit (#4271)
A new hatch release is out and that should work.
2026-03-02 13:56:44 +00:00
Sri Kaaviya
821e332d7e Fix falcon-instrumentation _handle_exception method to remove pylint disables (#4207)
* Fix falcon-instrumentation _handle_exception method to remove pylint disables

* Refactor _handle_exception method for Falcon 3

* try fix

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* Add CHANGELOG entry for falcon _handle_exception refactor (#4207)

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-03-02 11:27:24 +00:00
Ritesh Tripathi
4880e33217 fix(flask): align http.server.active_requests metric with semconv helper (#4094)
* fix(flask): correct HTTP metrics handling with semconv opt-in

* fix(flask): avoid hardcoded legacy http.server.duration metric name

* changelog: note flask http server metrics consistency fix

* fix(flask): use semconv constant for legacy http.server.duration metric

* Update instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

* Update CHANGELOG.md

* fix(flask): explicitly split active requests metric by semconv mode

* fix(flask): align http.server.active_requests metric with semconv helper

---------

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-03-02 11:24:07 +00:00
Mike Goldsmith
b865493be8 maint: Add stale github action (#4220)
* maint: Add stale github action

* add changelog entry

* add exempt PR labels

* increase close days to 14

* update contributing.md for stale PRs

* Update cron schedule

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* update stale message

* clean-up

---------

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
2026-03-02 11:31:59 +01:00
Sri Kaaviya
3fcabc3f41 asyncio: fix environment variables not appearing in docs (#4261)
* 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>
2026-03-02 08:47:10 +00:00
Riccardo Magliocchetti
60345f3ebe Add Keith Decker to approvers (#4273) 2026-03-02 09:31:27 +01:00
Riccardo Magliocchetti
367e5e08ab instrumentation-genai: stop setting OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true (#4263)
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.
2026-02-27 09:01:33 +00:00
Riccardo Magliocchetti
7e49db45ab confluent-kafka: add basic autoinstrumentation tests (#4266)
* confluent-kafka: test auto-instrumentation code path

* Add TODO to simpligy the instrumentation

* silence pylint

* Update __init__.py
2026-02-27 08:54:02 +00:00
Rima-ag
e1c56f2fc5 [google-genai] Test instrumentation on google-genai v1.64.0 (#4253)
* [google-genai] Test instrumentation on google-genai v1.63.0

* Add package version upper bound

* bump latest version for python 3.9

* fix README

* bump google-auth version for python 3.9

* add package upper limit to pyproject.toml

* [google-genai] Test instrumentation on google-genai v1.64.0

* fix upper case method in cassette not matching lower case one generated by aiohttp

* fix async calls hanging in vcrpy

* Remove package upper limit

* fix import error in python 3.9

* fix google-genai module lower bound

* Add link to vcr issue

* Add comment about request method

* Fix lint errors

* Fix spellcheck

---------

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
2026-02-27 00:29:04 -05:00
Dinmukhamed Mailibay
8fec6b672e fix(threading): attribute error when run is called w/o start (#4246)
* fix(threading): attribute error when run is called w/o start

* update changelog

* don't initialize context on run, fix tests

* address styling comments

* remove no-op context attachment
2026-02-26 15:33:15 +00:00
Riccardo Magliocchetti
7326faa491 Require virtualenv<21 for tox -e generate (#4265)
* 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>
2026-02-26 13:45:44 +00:00
Tammy Baylis
2b8ca97f91 Fix docker-tests assumption by Postgres-Sqlalchemy case about scope of metrics (#4258)
* Fix postgres-sqlalchemy docker-test assumption about metrics

* Changelog
2026-02-25 12:25:41 +01:00
otelbot[bot]
5560324cff Update opentelemetry-instrumentation-google-genai version to v0.8b0 (#4241)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2026-02-20 16:55:00 -05:00
Aaron Abbott
fed08a99f3 Fix util-genai version in google-genai instrumentation (#4239)
Fixes https://github.com/open-telemetry/opentelemetry-python-contrib/issues/4221
2026-02-20 16:43:14 -05:00
otelbot[bot]
be0c03e450 Update opentelemetry-util-genai version to v0.4b0 (#4236)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2026-02-20 11:13:18 -05:00
Liudmila Molkova
fd4fdf0ad9 Remove general instrumentation-genai owners group (#4004)
* remove general owners group

* record answers

* up

* remove some owners

---------

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-02-20 15:58:19 +00:00
Aaron Abbott
d6afdb94f3 Update package-prepare-release workflow to work when release was previously aborted (#4235) 2026-02-20 10:42:04 -05:00
Ritesh Tripathi
413c98e542 test(mysql): provide concrete DBAPI connection attributes in mocks (#4116)
* test(mysql): provide concrete DBAPI connection attributes in mocks

* test(mysql): pass concrete attributes via MagicMock helpers

* test(mysql): refactor mocks and remove redundant attribute assignments

* changelog: add mysql test mock fix entry

* test(mysql): refactor SQL commenter mocks into helper

* test(mysql): refactor SQL commenter mocks into helper

- Introduce make_mysql_commenter_mocks helper
- Remove duplicated MagicMock setup
- Preserve test assertions and behavior
- Improve readability and maintainability

* test(mysql): use concrete DBAPI connection attributes in mocks to fix attribute type warnings

* Update instrumentation/opentelemetry-instrumentation-mysql/tests/test_mysql_integration.py

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-02-20 12:32:59 +01:00
Aaron Abbott
87b20abdca Fix version of dependents of util-genai for release (#4230)
I missed a few more when making https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4224
2026-02-20 10:06:16 +01:00
Teja
a025a206da Anthropic agents boilerplate (#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 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.
2026-02-19 20:57:06 -05:00
Aaron Abbott
f189a1f56d Prepare anthropic and google-genai for util-genai release (#4224) 2026-02-19 18:20:35 -05:00
Ridhima Satam
e8fdc53e79 Add log and metrics provider to langchain (#4214)
* Added log and metrics provider to langchain

* updated changelog

* added line

* deleted handler

* removed multiple cassettes

* fixed ruff

* fixed spellcheck
2026-02-19 17:23:41 -05:00
Wiktoria Walczak
8c3cc8539f Align gen_ai.tool_definitions with JSON Schema and add it to completion hook (#4181)
* 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>
2026-02-19 15:17:40 -05:00
Emídio Neto
22e31a5571 Add python 3.14 support (#4193)
* try 3.14 in pyramid

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* see what's broken

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pyramid

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pyramid ci

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix sqlalchemy

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix httpx tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pymssql

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix grpc tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix exporter-prometheus-write tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* try fastapi fix

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix django tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix aiopg

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix aiohttp-client

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix django

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix aiopg

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix httpx

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix fastapi

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix vertexai

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix workflows

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix openai-v2

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix contributing.md and lint to use py314

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix lint

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* Update tox.ini

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>

* Update instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py

Co-authored-by: Aaron Abbott <aaronabbott@google.com>

* Apply suggestion from @emdneto

* Apply suggestion from @emdneto

* Update tox.ini

* Update tox.ini

* fix lint

Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* add changelog

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* add trove classifiers

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
2026-02-19 14:37:02 -05:00
Lukas Hering
1eca3e6b8e opentelemetry-instrumentation-aws-lambda: Fix aws lambda span creation (#3966)
* 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>
2026-02-16 10:45:09 +00:00
Andrea Mattè
d5aebefb51 cassandra: use _instruments_any instead of _instruments for driver deps (#4182)
* 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>
2026-02-13 12:31:13 +01:00
Minghui Zhang
93bea2dde7 opentelemetry-util-genai: add support for emitting inference events and enrich message types (#3994)
* Add support for emitting inference events and enrich message types

Change-Id: I8fd0b896fc103a986f78c7351ce627611e545a62
Co-developed-by: Cursor <noreply@cursor.com>

* Add change log

Change-Id: I5c4c93613e3e1084245b7298955a08cbc7c9708d
Co-developed-by: Cursor <noreply@cursor.com>

* Fix unit tests

Change-Id: If34cfce0e7eb130db6a1e8e30a5f4be7c215285f
Co-developed-by: Cursor <noreply@cursor.com>

* Fix linting failure

Change-Id: I847f75259e01729db88129a44b241afb0ea2aca4
Co-developed-by: Cursor <noreply@cursor.com>

* Fix readme

Change-Id: I818a042d275d3c8e3348647d73e34560e7d92f54
Co-developed-by: Cursor <noreply@cursor.com>

* Format codes

Change-Id: I40b8e01bbe4fa9c182e99085a7c71d4536042247
Co-developed-by: Cursor <noreply@cursor.com>

* Fix missing trace context in events

Change-Id: Ie07c495002143fb2f0cf88033206290eb85386ad
Co-developed-by: Cursor <noreply@cursor.com>

* feedback

Change-Id: Ida0c2305d950d978c31eb04a80e21e947fabdfba
Co-developed-by: Cursor <noreply@cursor.com>

* fix type check

Change-Id: I1da48b52b76042a9efd124057681f579cc93fb6e
Co-developed-by: Cursor <noreply@cursor.com>

* Fix the span name of LLM invocations

Change-Id: I1b9f40e5576e699b1f61fa3d7e7790ee4b1448a5
Co-developed-by: Cursor <noreply@cursor.com>

* Fix span name

Change-Id: I7adf6fc9cf0bcbed3927862ff87d441bb2a1f78b
Co-developed-by: Cursor <noreply@cursor.com>

* Fix operation name of llm span

Change-Id: I4a6f48d0f66b8ad00a6ce4be8dcf4a46aba68e33
Co-developed-by: Cursor <noreply@cursor.com>

* Adjust event emission switches to optimize the integration experience

Change-Id: Ied7182fe2f3493a1eba96d7eaae5fd1b790c16e7
Co-developed-by: Cursor <noreply@cursor.com>

* Resolve conflicts

Change-Id: I95472013fe59b2b7a7448bb4374fe103021ec8a1
Co-developed-by: Cursor <noreply@cursor.com>

* Fix lint error

Change-Id: I78008c9b812d81a705eb7e7c75bd622b47d9da5a
Co-developed-by: Cursor <noreply@cursor.com>

* Refactor span_utils.py to streamline attribute collection

Change-Id: I243cc757454c085818d621011435076bf501108d
Co-developed-by: Cursor <noreply@cursor.com>

* Fix the lint error

Change-Id: If8bfaf1fde5594f7918c195243db9ec83f156156
Co-developed-by: Cursor <noreply@cursor.com>

---------

Co-authored-by: Aaron Abbott <aaronabbott@google.com>
2026-02-10 12:16:29 -05:00
Antoine D
b8a80209d7 fix instrument of typed psycopg sql (#4171)
* 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>
2026-02-10 16:34:24 +00:00
Emídio Neto
36aa71b21c Add pypi.org as explicit default index for uv in pre-commit (#4167)
* Add pypi.org as explicit default index for uv

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* try modifying uv.lock pointing to artifact registry -- ci should fail

* try uv lock before

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* try wrong uv.lock

* test

* test

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* final test with wrong uv.lock -- precommit job should fail again

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix uv.lock -- ci should pass

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
2026-02-10 16:27:56 +00:00
Nagkumar Arkalgud
1e92f1ab0c fix(openai-v2): Add __getattr__ to StreamWrapper to proxy unknown attributes (#4184)
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>
2026-02-10 16:23:01 +00:00
Riccardo Magliocchetti
f64f04fe1a Add Lukas Hering as contrib approver (#4174) 2026-02-10 16:19:29 +00:00
Emídio Neto
5d09f06cf6 openai-v2(ci): reduce CI testing time by installing numpy manually (#4176)
* install numpy manually

Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* try numpy~=2.0

Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* fix

Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

---------

Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-02-10 17:13:27 +01:00
Anuraag (Rag) Agrawal
16f7be0719 Add scope to metric assertions in more tests (#4165)
* Add scope to metric assertions in more tests

* More

* Lint

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-02-10 14:51:06 +00:00
Riccardo Magliocchetti
a64940861a requirements: stick with older setuptools for packages still using pkg_resources (#4187)
* requirements: stick with older setuptools for packages still using pkg_resources

* Set build constraints for cassandra driver
2026-02-10 15:22:57 +01:00
Emídio Neto
6ae0f47561 aiohttp-server: fix HTTP error inconsistencies (#4175)
* aiohttp-server: fix HTTP error inconsistencies

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix failing test

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* changelog and fix pylint

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* changelog and fix pylint

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2026-02-06 16:56:04 +00:00
Ridhima Satam
e381a36718 Switched langchain llm callbacks to use genai utils handler (#3889)
* Removed telemetry from inference callbacks and added calls to genai utils apis instead.

* Fixed errors

* Fixed typecheck errors

* Fixed typecheck errors

* Fixed precommit errors

* added util dependancy

* updated invocation manager

* removed unnecessary dependancies

* fixed precommit

* fixed typecheck

* fixed precommit

* fixed test

* removed unnecessary line

* addressed comments

* fixed errors

* fixed precommit

* removed get_property_value method

* fixed format

* Make tox -e typecheck install langchain, and fixed some of the type
errors. The remaining ones seem like real issues that need to be fixed.

* Please fix reportPossiblyUnboundVariable

* fixed typecheck

* added and updated tests

* Fixed conflicts and removed unnecessary changes

* Fixed precommit

---------

Co-authored-by: aaronabbott <aaronabbott@google.com>
2026-02-06 09:55:32 -05:00
Wiktoria Walczak
e01a4c195d Fix changelog from #4142 (#4170) 2026-02-05 11:34:00 -05:00
Emídio Neto
8c84a3dfd2 fiv ux lock to use pythonhosted.org (#4164) 2026-02-05 09:44:12 +01:00