Skip to content

GenAI Utils: Adding Embedding metrics and events#1

Draft
shuningc wants to merge 61 commits intomainfrom
addingEmbeddingMetric
Draft

GenAI Utils: Adding Embedding metrics and events#1
shuningc wants to merge 61 commits intomainfrom
addingEmbeddingMetric

Conversation

@shuningc
Copy link
Copy Markdown
Owner

Description

This PR adds metrics and events telemetry for [EmbeddingInvocation], aligning with OpenTelemetry semantic conventions. Previously, embedding invocations only emitted spans - now they also emit duration metrics and operation details events.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [+] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added 3 new tests for embedding metrics:
[test_stop_embedding_records_duration_only] - verifies duration is recorded but token metrics are NOT
[test_stop_embedding_records_duration_with_additional_attributes] - verifies server address, port, custom attributes, and response model are included
[test_fail_embedding_records_error_and_duration] - verifies error path records
error.type and duration

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • [+] No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • [+] Followed the style guidelines of this project
  • [+] Changelogs have been updated
  • [+] Unit tests have been added
  • Documentation has been updated

xrmx and others added 30 commits March 5, 2026 16:36
* 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>
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…en-telemetry#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 open-telemetry#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
* 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
…telemetry#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>
…ry#4280)

* Add response wrappers for OpenAI Responses API streams.

* Enhance docstrings for ResponseStreamWrapper and ResponseStreamManagerWrapper to include references to the OpenAI SDK source. This improves clarity on the functionality and origin of the wrappers.

* Add wrappers for OpenAI Responses API streams and response stream managers in CHANGELOG.md

* Refactor response handling in OpenAI response wrappers to improve event processing and error handling. Introduced conditional imports for response events and error types, ensuring compatibility with missing modules. Updated event processing logic to utilize a consolidated response events tuple.

* Refactor OpenAI response wrappers to enhance error handling and event processing. Introduced context managers for safe instrumentation, improved import handling for response events, and streamlined response attribute extraction logic.

* Add unit tests for ResponseStreamManagerWrapper to validate error handling and stream finalization behavior.

* Remove unnecessary blank line in test_response_wrappers.py to improve code cleanliness.

* Refactor event handling in ResponseStreamWrapper to simplify type checks for response events. Removed unnecessary conditional checks for event types, enhancing code clarity and maintainability.

* Enhance ResponseStreamWrapper and ResponseStreamManagerWrapper with improved error handling and context management. Introduced ExitStack for better resource management and added NotImplementedError for unimplemented parse methods. Updated TODO comments for future refactoring with wrapt.ObjectProxy.
… upper bound to <3.0.0 (open-telemetry#4289)

* opentelemetry-instrumentation-confluent-kafka: Add support for confluent-kafka 2.13.2

* chore: Losen confluent-kafka upper bound to <3.0.0

---------

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

* increase stale action operations-per-run to 500

Assisted-by: Claude Sonnet 4.6

* add changelog entry for stale ops-per-run increase

Assisted-by: Claude Sonnet 4.6

* add TODO to revert once backlog is cleaned up

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Add support for wrapt 2.x

- Update wrapt version constraint from '>=1.0.0, <2.0.0' to '>=1.0.0' in all affected packages
- Replace ObjectProxy with BaseObjectProxy where iteration support is not needed
- Add fallback import for wrapt 1.x compatibility (ObjectProxy as BaseObjectProxy)
- Keep ObjectProxy usage in classes that implement __iter__ (botocore, aiopg)
- Update CHANGELOG.md

This change maintains backward compatibility with wrapt 1.x while enabling
support for wrapt 2.x. BaseObjectProxy is the new base class in wrapt 2.x,
while ObjectProxy is now a subclass that adds __iter__() support.

Fixes open-telemetry#3903
Related to open-telemetry#3930 and open-telemetry#4082

* Restructure wrapt test requirements

- Remove wrapt from base test-requirements.txt (installed via pyproject.toml)
- Remove Deprecated from base test-requirements.txt (version conflicts with wrapt 2.x)
- Create test-requirements-wrapt1.txt with wrapt<2.0.0 and Deprecated==1.2.14
- Create test-requirements-wrapt2.txt with wrapt>=2.0.0 and Deprecated>=1.2.18
- Update tox.ini to use requirements files instead of factor-based deps
- Add Deprecated to lint environment deps

This follows the pattern used by other packages (botocore, httpx) and
resolves dependency conflicts where Deprecated 1.2.14 requires wrapt<2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: Resolve conflicts and add Wrapt 3 as upper bound

* Add wrapt 1.x/2.x test matrix for all ObjectProxy-using instrumentations

Extend the wrapt1/wrapt2 test matrix to all instrumentations that use
wrapt.ObjectProxy or wrapt.BaseObjectProxy: botocore, dbapi, grpc, pika,
aiopg, httpx, and asyncpg.

Changes:
- tox.ini: Add {wrapt1,wrapt2} factor to envlist for all 7 packages;
  update deps to reference per-version test-requirements files
- botocore/pyproject.toml: Add missing wrapt dependency (>= 1.0.0, < 3.0.0)
- All base test-requirements files: Remove pinned wrapt== and Deprecated==
- New test-requirements-wrapt1.txt / test-requirements-wrapt2.txt files for
  each package (using Deprecated>=1.2.18 for wrapt2 to avoid conflict with
  Deprecated==1.2.14 which requires wrapt<2)
- Regenerate GitHub Actions workflows (including new test_3.yml due to
  expanded job count)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix CI failures: ruff formatting and lint wrapt version pin

- utils.py: reformat multi-condition if statement to satisfy ruff line
  length requirement (fixes generate/precommit CI jobs)
- tox.ini: pin wrapt>=1.0.0,<2.0.0 for lint envs of botocore, dbapi,
  grpc, and sio-pika; with wrapt 1.x removed from base test-requirements,
  lint envs were getting wrapt 2.x which caused pylint no-member errors
  on __wrapped__ (a C-extension attribute not visible to static analysis)
  Also add Deprecated==1.2.14 to same lint envs for consistency

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix remaining CI failures: unused imports and uv.lock

- dbapi/__init__.py: remove unused bare 'import wrapt' (F401); the
  compat shim imports BaseObjectProxy directly from wrapt
- grpc/_aio_server.py: remove unused 'import wrapt' (F401) and fix
  import ordering (I001) flagged by ruff pre-commit hook
- uv.lock: regenerate after adding wrapt dependency to botocore
  pyproject.toml

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix aiopg lint wrapt pin, uv.lock format, and ruff blank lines

- tox.ini: pin wrapt>=1.0.0,<2.0.0 + Deprecated==1.2.14 for
  lint-instrumentation-aiopg; aiopg source uses __wrapped__ heavily and
  pylint's no-member error appeared when wrapt 2.x was installed
- uv.lock: regenerate using pre-commit hook (uv v0.9.30) to fix
  trailing-slash format on registry URLs
- httpx/test_httpx_integration.py: add blank line before try/except
  block (ruff I001/E303 formatting fix)
- pika/utils.py: add blank line before try/except block (same ruff fix)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix pylint E0611: disable no-name-in-module for BaseObjectProxy compat shim

pylint with wrapt 1.x installed reports E0611 ('No name BaseObjectProxy
in module wrapt') when it sees the try/except ImportError compat shim,
even though the except branch provides a fallback. Add a per-line
pylint disable comment to suppress this false positive.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix asyncpg test: use BaseObjectProxy compat shim for wrapt 2.x

In wrapt 2.x, BoundFunctionWrapper no longer subclasses ObjectProxy
(it subclasses BaseObjectProxy instead). Update the test to use
the compat shim so isinstance checks pass with both wrapt 1.x and 2.x.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address PR review comments: add wrapt 2.0.0+ comments and fix CHANGELOG

- Add '# wrapt 2.0.0+' comment above BaseObjectProxy import in all
  try/except compat shim blocks to clarify why the pattern is used
- Fix CHANGELOG.md PR link from #XXXX to open-telemetry#4203

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Apply suggestions from code review

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

* chore: Update changelog and workflows

* Apply suggestions from code review

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

* fix: Update workflows again

* Apply suggestions from code review

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

* Remove Deprecated version pins from test-requirements and tox.ini

Deprecated>=1.2.14 was pinned because Deprecated==1.2.14 requires
wrapt<2. Since pip automatically resolves compatible versions based
on the wrapt constraint in each test env, explicit Deprecated pins
are unnecessary. Remove them from all test-requirements-wrapt*.txt
files and from lint env deps in tox.ini.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove stale .orig file leftover from rebase

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Move lint env wrapt pins from tox.ini into test-requirements files

All dependencies should be managed via requirements.txt files rather
than inline in tox.ini. Move wrapt>=1.0.0,<2.0.0 pins for lint
environments into their respective test-requirements files:
- instrumentation-grpc/test-requirements-1.txt
- instrumentation-botocore/test-requirements-1.txt
- instrumentation-dbapi/test-requirements.txt
- instrumentation-aiopg/test-requirements.txt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Apply suggestions from code review

* Update instrumentation/opentelemetry-instrumentation-botocore/test-requirements-1.txt

* Update instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt

* Update instrumentation/opentelemetry-instrumentation-dbapi/test-requirements.txt

* Update instrumentation/opentelemetry-instrumentation-aiopg/test-requirements.txt

* Address latest PR feedback: botocore compat shim, exact wrapt versions, lint env refs

- botocore/bedrock_utils.py: apply BaseObjectProxy compat shim to
  ConverseStreamWrapper and InvokeModelWithResponseStreamWrapper (both
  classes define __iter__ so BaseObjectProxy is correct)
- All test-requirements-wrapt1.txt: pin wrapt==1.17.3 (exact version)
- All test-requirements-wrapt2.txt: pin wrapt==2.1.2 (exact version)
- tox.ini lint envs: switch to -wrapt2.txt files so lint runs with
  wrapt 2.x; remove wrapt pin from base test-requirements files
  (grpc/test-requirements-1.txt, botocore/test-requirements-1.txt,
  dbapi/test-requirements.txt, aiopg/test-requirements.txt)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: add pylint disable=no-member for __wrapped__ and abstract-method usages

Add pylint: disable=no-member to all class definitions and usages of
__wrapped__ that are invisible to pylint when using wrapt's C extension
proxy types (BaseObjectProxy/ObjectProxy).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Remove boto instrumentation

* Add changelog

* Run tox -e generate
* add schema_url to metrics

* changelog

* review

* simplify further

* simplify further

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…metry#4321)

* fix: don't import module in unwrap if not already

* Changelog

* Make test clearer

* Update CHANGELOG.md

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

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* pylint: use unnecessary-dunder-call instead of E1101

Since pylint 4 now raises a different error code

* opentelemetry-instrumentation-sqlite3: fix pylint warnings

Possibly using variable 'root_span' before assignment (possibly-used-before-assignment)
Possibly using variable 'child_span' before assignment (possibly-used-before-assignment)

* opentelemetry-instrumentation-botocore: silence a bunch of pylint warnings

In the form of
Possibly using variable '<var>' before assignment (possibly-used-before-assignment)

* opentelemetry-instrumentation-redis: remove useless return spotted by pylint

* opentelemetry-instrumentation-fastapi: silence some pylint warnings

E0102: function already defined line 2034 (function-redefined)

* opentelemetry-instrumentation-google-genai: fix pylint warnings

Assisted by Cursor.

* opentelemetry-instrumentation-openai-v2: fix pylint 4 errors

Assisted by Cursor

* opentelemetry-instrumentation-elasticsearch: fix pylint 4 errors

Assisted by Cursor.

* opentelemetry-instrumentation-pika: fix pylint 4 errors

Assisted by cursor.

* opentelemetry-instrumentation-starlette: fix pylint 4 errors

* opentelemetry-instrumentation: fix pylint 4 errors

Assisted by Cursor.

* opentelemetry-util-http: fix pylint 4 errors
…pen-telemetry#4299)

Bumps [django](https://github.com/django/django) from 4.2.17 to 4.2.29.
- [Commits](django/django@4.2.17...4.2.29)

---
updated-dependencies:
- dependency-name: django
  dependency-version: 4.2.29
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…n-telemetry#4212)

* feat: add support for capture_parameters to Psycopg2Instrumentor

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Build list of required jobs in generate-workflow

Dump the list of all the jobs in the same format that is required for
configuration in opentelemetry-admin terraform config files so that
we don't miss required jobs.

* Serialize also misc jobs

* Document what this script is about
* Add workflow type in genai utils

* fixed errors

* fixed errors

* fixed test

* fixed test

* fixed precommit

* moved to unreleased

* reordered
…pen-telemetry#4302)

* fix: Add recursion guard in LoggingHandler.emit to prevent deadlock

LoggingHandler.emit() can deadlock when _translate() triggers internal
logging (e.g., _clean_extended_attribute calling _logger.warning() for
invalid attribute types). The warning re-enters the handler chain on the
same thread, creating infinite recursion that prevents the handler lock
from ever being released, blocking all other threads.

This adds a ContextVar-based guard that detects re-entrant calls to
emit() on the same thread and skips the recursive call, preventing the
deadlock while preserving all application logs.

Fixes open-telemetry/opentelemetry-python#3858
Relates to open-telemetry/opentelemetry-python#3560
Relates to open-telemetry/opentelemetry-python#4585

* Update CHANGELOG.md

---------

Co-authored-by: Deepanshu Kartikey <kartikey406@gmail.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* feat: wrappers for async responses methods.

* wip: updating changelog.

* wip: refactoring for precommit and linting.

* refactor: adding defensive guard against stream's response.
…emetry#4332)

* chore(util-genai): migrate handler metrics test to TestBase

* Formatting

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
…lemetry#1180) (open-telemetry#4259)

* Fix gRPC client interceptor breaking bidirectional streaming (open-telemetry#1180)

Route bidi (stream-stream) RPCs through `_intercept` instead of the
generator-based `_intercept_server_stream`. The generator wrapper strips
the grpc.Call/grpc.Future interface, causing downstream code (e.g.
google.api_core.bidi.BidiRpc) to crash with:

    AttributeError: 'generator' object has no attribute 'add_done_callback'

The fix adds `and not client_info.is_client_stream` to the condition in
`intercept_stream()` so only unary-stream RPCs use the generator path.

Includes a regression test verifying the bidi stream response preserves
the grpc.Call interface (add_done_callback, cancel, is_active).

Co-authored-by: Cursor <cursoragent@cursor.com>

* Add gRPC status code attributes to error handling in client

* Remove redundant status description from span error status

The gRPC status code is already captured in the RPC_GRPC_STATUS_CODE
attribute, making the description in span status unnecessary.

* Update CHANGELOG.md

* Update CHANGELOG.md

* Add RPC_GRPC_STATUS_CODE assertions to client error tests

Verify that error spans include the correct gRPC status code attribute
(INVALID_ARGUMENT) in both sync and async client interceptor tests.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* initial implementation for aiobotocore instrumentation

* fix failing tests

* add basic set of tests for aiobotocore instrumentation

* update CHANGELOG.md

* address comments and update tests to run with and without aiobotocore installed

* update workflows and fix lock file

* update tests

* fix lint

* Update botocore documentation to include aiobotocore

* update bootstrap_gen.py

* update botocore instrumentation test deps

* update uv.lock

* fix CHANGELOG.md and remove unused variable in tests

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
open-telemetry#4339)

* refactor(docker-tests): replace SpanAttributes with semconv attributes

Refs open-telemetry#3475

* update changelog for PR open-telemetry#4339

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dae46693-1ed4-451c-93f1-0333bc952789

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch addingEmbeddingMetric

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shuningc shuningc marked this pull request as draft March 30, 2026 12:39
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

GenAI Embedding Metrics, OpAMP Client, and Instrumentation Enhancements

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Added EmbeddingInvocation dataclass to GenAI types with embedding-specific attributes and
  metrics support
• Refactored metrics recording in metrics.py to support both LLMInvocation and
  EmbeddingInvocation, with token metrics only recorded for LLM invocations
• Added generic _start, _stop, and fail methods in handler.py supporting any
  GenAIInvocation subclass, plus new embedding context manager
• Added embedding span and event handling utilities in span_utils.py including common attributes,
  span naming, and event emission
• Added comprehensive embedding metrics tests validating duration recording, additional attributes,
  and error handling
• Refactored tool call types: renamed ToolCall to ToolCallRequest, added ServerToolCall,
  ServerToolCallResponse, and WorkflowInvocation dataclasses
• Enhanced Anthropic instrumentation with streaming support, message/stream wrappers, and extraction
  helpers
• Added OpenAI v2 response stream wrappers with telemetry integration for handling streaming
  responses
• Implemented OpAMP client with agent, message building, and transport layer for agent communication
• Added aiobotocore async instrumentation with extension registry for AWS SDK instrumentation
  management
• Multiple test suite additions for OpAMP, Anthropic, OpenAI, and botocore instrumentations
• Updated semantic convention attribute imports across multiple test files (asyncpg, redis, celery,
  pymongo)
• Fixed confluent-kafka and wrapt 2.0 compatibility issues
• Removed deprecated boto instrumentation package
Diagram
flowchart LR
  A["EmbeddingInvocation Type"] -->|"supports"| B["Metrics Recording"]
  A -->|"supports"| C["Span & Event Handling"]
  B -->|"duration only"| D["Embedding Metrics"]
  C -->|"embedding-specific"| E["Span Utils"]
  F["GenAI Handler"] -->|"generic methods"| G["LLM & Embedding Support"]
  H["OpAMP Client"] -->|"agent communication"| I["Message Building"]
  H -->|"transport"| J["HTTP with TLS"]
  K["Anthropic Instrumentation"] -->|"streaming"| L["Message Wrappers"]
  M["OpenAI v2"] -->|"streaming"| N["Response Wrappers"]
  O["Botocore"] -->|"async support"| P["Aiobotocore Instrumentation"]
Loading

Grey Divider

File Changes

1. opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/proto/opamp_pb2.py Dependencies +144/-0

Generated OpAMP protocol buffer Python bindings

• Generated protocol buffer code for OpAMP protocol definitions
• Includes message definitions for agent-to-server and server-to-agent communication
• Defines enums for capabilities, status, and package management
• Auto-generated file from opamp.proto source

opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/proto/opamp_pb2.py


2. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/test_sync_messages.py 🧪 Tests +647/-8

Expanded Anthropic instrumentation tests with streaming and cache support

• Added helper functions for normalizing stop reasons and computing input tokens including cache
 tokens
• Added new test cases for streaming message creation, content capture, tool use, and thinking
 blocks
• Added tests for error handling, stream wrapper finalization, and cache token aggregation
• Added EVENT_ONLY content capture mode tests

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/test_sync_messages.py


3. util/opentelemetry-util-genai/tests/test_utils.py 🧪 Tests +164/-294

Added embedding invocation telemetry tests and updated log exporter imports

• Updated import from InMemoryLogRecordExporter to InMemoryLogExporter
• Added tests for embedding invocation span creation and parent-child relationships
• Added tests for mixed LLM parent with embedding child spans
• Added embedding error handling and context manager tests

util/opentelemetry-util-genai/tests/test_utils.py


View more (136)
4. instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py ✨ Enhancement +227/-120

Added aiobotocore async instrumentation and refactored extension management

• Updated documentation to include both botocore and aiobotocore support
• Added new AiobotocoreInstrumentor class for async AWS SDK instrumentation
• Refactored instrumentation logic to use ExtensionRegistry for managing extensions
• Added header injection check to prevent double-injection when both instrumentors are active

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/init.py


5. tests/opentelemetry-docker-tests/tests/asyncpg/test_asyncpg_functional.py Formatting +60/-96

Migrated asyncpg tests to incubating semantic convention attributes

• Updated imports to use incubating semantic convention attributes directly instead of
 SpanAttributes
• Replaced all SpanAttributes.* references with direct attribute imports (DB_SYSTEM, DB_NAME,
 etc.)
• Updated database and network attribute assertions throughout test cases

tests/opentelemetry-docker-tests/tests/asyncpg/test_asyncpg_functional.py


6. instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_response_wrappers.py 🧪 Tests +458/-0

Added comprehensive tests for OpenAI response stream wrappers

• New test file for response wrapper classes in OpenAI v2 instrumentation
• Tests for ResponseStreamManagerWrapper and ResponseStreamWrapper synchronous wrappers
• Tests for AsyncResponseStreamManagerWrapper and AsyncResponseStreamWrapper async wrappers
• Covers exception handling, stream finalization, and event processing

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_response_wrappers.py


7. instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/response_wrappers.py ✨ Enhancement +464/-0

OpenAI Responses API stream wrappers with telemetry integration

• New file implementing wrapper classes for OpenAI Responses API streams and stream managers
• Provides both synchronous and asynchronous wrapper implementations for handling streaming
 responses
• Integrates telemetry handling through TelemetryHandler for tracking LLM invocations
• Implements context managers and iterator protocols for proper resource cleanup and event
 processing

instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/response_wrappers.py


8. opamp/opentelemetry-opamp-client/tests/opamp/test_client.py 🧪 Tests +446/-0

OpAMP client unit tests with comprehensive coverage

• New comprehensive test suite for OpAMP client functionality
• Tests client instantiation with default and custom parameters
• Validates message building, serialization, and remote config handling
• Covers error scenarios and edge cases for OpAMP protocol operations

opamp/opentelemetry-opamp-client/tests/opamp/test_client.py


9. instrumentation/opentelemetry-instrumentation-botocore/tests/test_aiobotocore_instrumentation.py 🧪 Tests +460/-0

Aiobotocore async instrumentation test suite

• New test suite for aiobotocore async instrumentation
• Tests EC2 and S3 client tracing with stubbed responses
• Validates error handling, suppression, and request/response hooks
• Covers multiple sequential operations and NoOp tracer provider scenarios

instrumentation/opentelemetry-instrumentation-botocore/tests/test_aiobotocore_instrumentation.py


10. util/opentelemetry-util-genai/tests/test_utils_events.py 🧪 Tests +380/-0

GenAI telemetry event emission test suite

• New test suite for GenAI telemetry event emission
• Tests event creation with various content capturing modes
• Validates error event handling and event context correlation with spans
• Covers default behavior for different content capturing configurations

util/opentelemetry-util-genai/tests/test_utils_events.py


11. opamp/opentelemetry-opamp-client/tests/opamp/test_agent.py 🧪 Tests +408/-0

OpAMP agent unit tests with retry and callback logic

• New comprehensive test suite for OpAMP agent functionality
• Tests agent lifecycle (start, stop, send operations)
• Validates retry logic, exponential backoff, and message dispatch ordering
• Covers error handling and callback invocation patterns

opamp/opentelemetry-opamp-client/tests/opamp/test_agent.py


12. instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/utils.py ✨ Enhancement +214/-116

Anthropic instrumentation utility functions refactoring

• Refactored utility functions for Anthropic instrumentation
• Added content block conversion utilities for handling various Anthropic message types
• Implemented stream block state management for streaming responses
• Added base64 blob extraction and finish reason normalization helpers

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/utils.py


13. tests/opentelemetry-docker-tests/tests/redis/test_redis_functional.py ⚙️ Configuration changes +37/-72

Redis instrumentation test semantic convention attribute updates

• Updated imports to use specific semantic convention attributes instead of SpanAttributes
• Replaced SpanAttributes.DB_REDIS_DATABASE_INDEX with DB_REDIS_DATABASE_INDEX
• Replaced SpanAttributes.NET_PEER_NAME/PORT with NET_PEER_NAME/PORT
• Replaced SpanAttributes.DB_STATEMENT with DB_STATEMENT

tests/opentelemetry-docker-tests/tests/redis/test_redis_functional.py


14. opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/agent.py ✨ Enhancement +304/-0

OpAMP agent with threading and retry management

• New OpAMP agent implementation with worker and scheduler threads
• Handles periodic heartbeat messages and on-demand requests with retry logic
• Implements exponential backoff with jitter for failed jobs
• Provides graceful shutdown and message processing with callback support

opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/agent.py


15. instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/wrappers.py ✨ Enhancement +275/-0

Anthropic message and stream response wrappers

• New wrapper classes for Anthropic message responses and streaming
• MessageWrapper handles non-streaming message telemetry extraction
• MessagesStreamWrapper manages streaming response telemetry with chunk processing
• Implements proper error handling and resource cleanup with context managers

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/wrappers.py


16. util/opentelemetry-util-genai/src/opentelemetry/util/genai/metrics.py ✨ Enhancement +77/-48

GenAI metrics recorder refactoring for embedding support

• Refactored metrics recording to support both LLMInvocation and EmbeddingInvocation
• Added _build_attributes static method for flexible attribute extraction
• Token metrics now only recorded for LLMInvocation instances
• Duration metrics recorded for all GenAIInvocation types

util/opentelemetry-util-genai/src/opentelemetry/util/genai/metrics.py


17. instrumentation/opentelemetry-instrumentation-botocore/test-requirements-0-wrapt1.txt Dependencies +2/-0

Botocore test requirements for wrapt compatibility

• New test requirements file for wrapt version 1.17.3
• Extends base test requirements with specific wrapt version constraint

instrumentation/opentelemetry-instrumentation-botocore/test-requirements-0-wrapt1.txt


18. util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py ✨ Enhancement +167/-8

Add embedding invocation type and refactor tool call types

• Added GenericPart dataclass for provider-specific message part types
• Renamed ToolCall to ToolCallRequest and added documentation distinguishing it from execution
 tracking
• Added ServerToolCall and ServerToolCallResponse dataclasses for server-side tool invocations
• Added WorkflowInvocation dataclass for predetermined sequences of operations
• Added EmbeddingInvocation dataclass with embedding-specific attributes and metrics support
• Refactored ToolCall as a GenAIInvocation subclass for execution tracking with spans and
 metrics
• Updated MessagePart union to include new types and GenericPart
• Added error_type and monotonic_start_s fields to GenAIInvocation base class

util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py


19. util/opentelemetry-util-genai/tests/test_handler_metrics.py 🧪 Tests +157/-32

Add embedding metrics tests and refactor test infrastructure

• Migrated test class from TestCase to TestBase for improved test infrastructure
• Added schema URL validation for metrics using _assert_metric_scope_schema_urls
• Added three new embedding metrics tests: duration-only recording, duration with additional
 attributes, and error handling
• Refactored _harvest_metrics to use get_sorted_metrics helper from TestBase
• Added SCOPE constant and improved metrics collection documentation

util/opentelemetry-util-genai/tests/test_handler_metrics.py


20. tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py Dependencies +27/-65

Update celery tests to use new semantic convention attributes

• Replaced deprecated SpanAttributes imports with specific attribute imports from
 _incubating.attributes
• Updated all span attribute references to use imported constants instead of SpanAttributes class
• Simplified attribute access patterns throughout test assertions

tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py


21. util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py ✨ Enhancement +119/-34

Add generic invocation lifecycle methods and embedding support

• Added generic _start, _stop, and _fail methods supporting any GenAIInvocation subclass
• Added public start, stop, and fail methods as generic entry points
• Added embedding context manager for embedding invocations
• Refactored LLM-specific methods to use generic implementations
• Added support for EmbeddingInvocation with embedding-specific span and event handling
• Improved error handling with try-finally blocks to ensure span cleanup
• Added schema URL to meter provider initialization

util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py


22. instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/messages_extractors.py ✨ Enhancement +219/-0

Add Anthropic messages extraction helper functions

• New file providing extraction helpers for Anthropic Messages instrumentation
• Defines MessageRequestParams dataclass for request parameter handling
• Implements token usage extraction with cache-related token support
• Provides functions to extract input/output messages and system instructions
• Includes server address and port extraction from client configuration

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/messages_extractors.py


23. instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/registry.py ✨ Enhancement +216/-0

Add AWS SDK extension registry for instrumentation management

• New file implementing ExtensionRegistry for AWS SDK extension management
• Manages lookup and caching of tracers, loggers, meters, and metrics per extension
• Provides methods to get appropriate extensions for call contexts
• Implements lazy initialization of instrumentation components with schema URLs

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/registry.py


24. util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py ✨ Enhancement +130/-8

Add embedding span and event handling utilities

• Added _get_embedding_common_attributes for embedding-specific common attributes
• Added _get_span_name generic function and embedding-specific _get_embedding_span_name
• Added _maybe_emit_embedding_event for embedding operation detail events
• Added _apply_embedding_finish_attributes for embedding span attribute application
• Added _get_embedding_request_attributes and _get_embedding_response_attributes
• Updated _apply_error_attributes to accept error_type string parameter
• Updated _maybe_emit_llm_event to accept error_type string instead of Error object

util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py


25. opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/client.py ✨ Enhancement +197/-0

Add OpAMP client implementation for agent communication

• New file implementing OpAMPClient for OpAMP protocol message building and sending
• Provides methods for building heartbeat, disconnect, and full state messages
• Implements remote config status tracking and updates
• Handles message encoding and HTTP transport with TLS support

opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/client.py


26. opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/messages.py ✨ Enhancement +189/-0

Add OpAMP message building and encoding utilities

• New file providing OpAMP message building and encoding utilities
• Implements protobuf message encoding for agent descriptions and configurations
• Provides remote config decoding with JSON support
• Handles AnyValue type encoding for attributes

opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/messages.py


27. instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_choice_buffer.py 🧪 Tests +182/-0

Add choice buffer tests for tool call argument handling

• New file with comprehensive tests for ChoiceBuffer and ToolCallBuffer classes
• Tests handle edge case where OpenAI-compatible providers send arguments=None on tool-call deltas
• Includes regression tests for issue #4344 covering multiple tool calls and None handling
• Tests standard OpenAI flow with empty string arguments

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_choice_buffer.py


28. opamp/opentelemetry-opamp-client/tests/opamp/transport/test_requests.py 🧪 Tests +178/-0

Add OpAMP requests transport tests

• New file with tests for RequestsTransport HTTP transport implementation
• Tests basic instantiation, message sending, and TLS/mTLS configuration
• Includes tests for error handling and timeout conversion
• Validates header merging and certificate handling

opamp/opentelemetry-opamp-client/tests/opamp/transport/test_requests.py


29. docs/conf.py ⚙️ Configuration changes +30/-7

Update documentation configuration for OpAMP support

• Replaced hardcoded path strings with variable references for maintainability
• Added opamp directory configuration to documentation build paths
• Updated aiohttp documentation URL to current location
• Added nitpick ignore entries for OpAMP protobuf types

docs/conf.py


30. instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py 🧪 Tests +37/-0

Add xfail markers for unhandled bedrock model families

• Added pytest.xfail calls for unhandled model families in multiple test functions
• Ensures tests fail gracefully with informative messages for unsupported models
• Improves test robustness by preventing silent failures on edge cases

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py


31. instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/patch.py ✨ Enhancement +85/-30

Refactor Anthropic messages instrumentation for streaming support

• Refactored messages_create wrapper to support both streaming and non-streaming responses
• Added MessagesStreamWrapper and MessageWrapper for response handling
• Implemented manual lifecycle management instead of context manager for better control
• Added content capture configuration support
• Improved error handling with explicit exception catching and error reporting

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/patch.py


32. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/conftest.py 🧪 Tests +74/-9

Add semantic convention stability and event-only capture fixtures

• Added semantic convention stability configuration to test fixtures
• Added instrument_event_only fixture for EVENT_ONLY content capture mode
• Improved fixture cleanup with try-finally blocks
• Added response header scrubbing for sensitive data
• Updated environment variable configuration for content capture modes

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/conftest.py


33. instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/test_tracer.py 🧪 Tests +57/-20

Update OpenAI agents test for invoke operation and tool definitions

• Renamed test from test_agent_create_span_records_attributes to
 test_agent_invoke_span_records_attributes
• Updated test to use invoke_agent operation instead of create_agent
• Added FunctionTool import and expanded response mock with tools and instructions
• Added assertions for system instructions and tool definitions in span attributes

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/test_tracer.py


34. util/opentelemetry-util-genai/tests/test_toolcall.py 🧪 Tests +118/-0

Add tool call type tests for inheritance and message usage

• New file with comprehensive tests for ToolCallRequest, ToolCall, ServerToolCall, and
 ServerToolCallResponse
• Tests inheritance relationships and usage as message parts
• Validates optional field handling and type literals
• Includes end-to-end message composition tests

util/opentelemetry-util-genai/tests/test_toolcall.py


35. opamp/opentelemetry-opamp-client/tests/opamp/test_e2e.py 🧪 Tests +126/-0

Add OpAMP end-to-end integration tests

• New file with end-to-end tests for OpAMP agent communication
• Tests connection, remote config status updates, and heartbeat flow
• Includes test for server unavailability scenarios
• Uses VCR for recording and replaying HTTP interactions

opamp/opentelemetry-opamp-client/tests/opamp/test_e2e.py


36. instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py 🐞 Bug fix +78/-4

Fix confluent kafka tests for empty operation span handling

• Removed empty span expectations from poll and consume test cases
• Added new tests for empty poll/consume operations not creating spans
• Added tests verifying cleanup of span and context token on empty operations
• Updated comments to clarify empty operation behavior

instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py


37. opentelemetry-instrumentation/tests/test_utils.py 🐞 Bug fix +31/-16

Update unwrap utility for wrapt 2.0 compatibility

• Updated imports to handle wrapt 2.0.0+ BaseObjectProxy with fallback to ObjectProxy
• Changed unwrap behavior to be no-op for non-imported modules instead of raising errors
• Added test for no-op behavior when module not imported
• Updated test expectations to reflect new no-op behavior

opentelemetry-instrumentation/tests/test_utils.py


38. tests/opentelemetry-docker-tests/tests/pymongo/test_pymongo_functional.py Dependencies +14/-12

Update pymongo tests to use new semantic convention attributes

• Replaced deprecated SpanAttributes imports with specific attribute imports from
 _incubating.attributes
• Updated all span attribute references to use imported constants
• Simplified attribute access patterns in assertions

tests/opentelemetry-docker-tests/tests/pymongo/test_pymongo_functional.py


39. .github/workflows/core_contrib_test_0.yml Additional files +493/-39

...

.github/workflows/core_contrib_test_0.yml


40. .github/workflows/generate_required_checks.py Additional files +42/-0

...

.github/workflows/generate_required_checks.py


41. .github/workflows/generate_workflows_lib/src/generate_workflows_lib/core_contrib_test.yml.j2 Additional files +4/-0

...

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/core_contrib_test.yml.j2


42. .github/workflows/generate_workflows_lib/src/generate_workflows_lib/lint.yml.j2 Additional files +2/-3

...

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/lint.yml.j2


43. .github/workflows/generate_workflows_lib/src/generate_workflows_lib/misc.yml.j2 Additional files +2/-3

...

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/misc.yml.j2


44. .github/workflows/generate_workflows_lib/src/generate_workflows_lib/test.yml.j2 Additional files +2/-3

...

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/test.yml.j2


45. .github/workflows/lint_0.yml Additional files +21/-22

...

.github/workflows/lint_0.yml


46. .github/workflows/misc_0.yml Additional files +2/-3

...

.github/workflows/misc_0.yml


47. .github/workflows/package-prepare-patch-release.yml Additional files +1/-0

...

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


48. .github/workflows/package-prepare-release.yml Additional files +1/-0

...

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


49. .github/workflows/package-release.yml Additional files +1/-0

...

.github/workflows/package-release.yml


50. .github/workflows/stale.yml Additional files +2/-0

...

.github/workflows/stale.yml


51. .github/workflows/test_0.yml Additional files +691/-692

...

.github/workflows/test_0.yml


52. .github/workflows/test_1.yml Additional files +1134/-1135

...

.github/workflows/test_1.yml


53. .github/workflows/test_2.yml Additional files +1954/-815

...

.github/workflows/test_2.yml


54. .github/workflows/test_3.yml Additional files +583/-0

...

.github/workflows/test_3.yml


55. .pylintrc Additional files +2/-2

...

.pylintrc


56. CHANGELOG.md Additional files +31/-0

...

CHANGELOG.md


57. README.md Additional files +1/-1

...

README.md


58. RELEASING.md Additional files +2/-0

...

RELEASING.md


59. docs-requirements.txt Additional files +6/-2

...

docs-requirements.txt


60. docs/index.rst Additional files +8/-0

...

docs/index.rst


61. docs/instrumentation/boto/boto.rst Additional files +0/-7

...

docs/instrumentation/boto/boto.rst


62. docs/opamp/client.rst Additional files +7/-0

...

docs/opamp/client.rst


63. docs/performance/benchmarks.rst Additional files +5/-1

...

docs/performance/benchmarks.rst


64. eachdist.ini Additional files +2/-0

...

eachdist.ini


65. exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt Additional files +1/-1

...

exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt


66. exporter/opentelemetry-exporter-richconsole/test-requirements.txt Additional files +1/-1

...

exporter/opentelemetry-exporter-richconsole/test-requirements.txt


67. instrumentation-genai/opentelemetry-instrumentation-anthropic/CHANGELOG.md Additional files +5/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/CHANGELOG.md


68. instrumentation-genai/opentelemetry-instrumentation-anthropic/pyproject.toml Additional files +5/-12

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/pyproject.toml


69. instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/__init__.py Additional files +5/-2

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/src/opentelemetry/instrumentation/anthropic/init.py


70. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_stream_wrapper_finalize_idempotent.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_stream_wrapper_finalize_idempotent.yaml


71. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_aggregates_cache_tokens.yaml Additional files +140/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_aggregates_cache_tokens.yaml


72. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_api_error.yaml Additional files +9/-346

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_api_error.yaml


73. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_basic.yaml Additional files +24/-737

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_basic.yaml


74. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_captures_content.yaml Additional files +140/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_captures_content.yaml


75. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_captures_thinking_content.yaml Additional files +149/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_captures_thinking_content.yaml


76. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_captures_tool_use_content.yaml Additional files +168/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_captures_tool_use_content.yaml


77. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_event_only_no_content_in_span.yaml Additional files +140/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_event_only_no_content_in_span.yaml


78. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_instrumentation_error_swallowed.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_instrumentation_error_swallowed.yaml


79. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_stop_reason.yaml Additional files +24/-412

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_stop_reason.yaml


80. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_stream_propagation_error.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_stream_propagation_error.yaml


81. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming.yaml


82. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_aggregates_cache_tokens.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_aggregates_cache_tokens.yaml


83. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_captures_content.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_captures_content.yaml


84. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_delegates_response_attribute.yaml Additional files +147/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_delegates_response_attribute.yaml


85. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_iteration.yaml Additional files +147/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_iteration.yaml


86. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_user_exception.yaml Additional files +138/-0

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_streaming_user_exception.yaml


87. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_token_usage.yaml Additional files +24/-412

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_token_usage.yaml


88. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_with_all_params.yaml Additional files +26/-438

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/cassettes/test_sync_messages_create_with_all_params.yaml


89. instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/requirements.oldest.txt Additional files +4/-5

...

instrumentation-genai/opentelemetry-instrumentation-anthropic/tests/requirements.oldest.txt


90. instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/pyproject.toml Additional files +5/-11

...

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/pyproject.toml


91. instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/tests/requirements.oldest.txt Additional files +3/-3

...

instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/tests/requirements.oldest.txt


92. instrumentation-genai/opentelemetry-instrumentation-google-genai/pyproject.toml Additional files +4/-4

...

instrumentation-genai/opentelemetry-instrumentation-google-genai/pyproject.toml


93. instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/message.py Additional files +19/-26

...

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/message.py


94. instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/base.py Additional files +1/-2

...

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/base.py


95. instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/requirements.oldest.txt Additional files +5/-5

...

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/requirements.oldest.txt


96. instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/callback_handler.py Additional files +8/-3

...

instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/callback_handler.py


97. instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/CHANGELOG.md Additional files +5/-0

...

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/CHANGELOG.md


98. instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py Additional files +36/-23

...

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py


99. instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/stubs/agents/tracing/__init__.py Additional files +11/-6

...

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/stubs/agents/tracing/init.py


100. instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/test_z_span_processor_unit.py Additional files +8/-23

...

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/tests/test_z_span_processor_unit.py


101. instrumentation-genai/opentelemetry-instrumentation-openai-v2/CHANGELOG.md Additional files +6/-0

...

instrumentation-genai/opentelemetry-instrumentation-openai-v2/CHANGELOG.md


102. instrumentation-genai/opentelemetry-instrumentation-openai-v2/pyproject.toml Additional files +5/-10

...

instrumentation-genai/opentelemetry-instrumentation-openai-v2/pyproject.toml


103. instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py Additional files +11/-7

...

instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py


104. instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/utils.py Additional files +5/-3...

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Mar 30, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. None provider attribute set 🐞 Bug ⛯ Reliability
Description
_get_embedding_common_attributes() always includes gen_ai.provider.name even when
EmbeddingInvocation.provider is None (the default). The new TelemetryHandler.embedding() path
creates EmbeddingInvocation() without a provider, so stop()/fail() can attempt to apply an
attribute with a None value to spans/events.
Code

util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[R85-88]

+    return {
+        GenAI.GEN_AI_OPERATION_NAME: invocation.operation_name,
+        GenAI.GEN_AI_PROVIDER_NAME: invocation.provider,
+        **{key: value for key, value in optional_attrs if value is not None},
Evidence
TelemetryHandler.embedding() instantiates EmbeddingInvocation() with default fields, where
provider is optional and defaults to None; _apply_embedding_finish_attributes() then sets
attributes built from _get_embedding_common_attributes(), which unconditionally includes
GEN_AI_PROVIDER_NAME: invocation.provider (potentially None).

util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py[274-295]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py[337-349]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[73-89]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[294-311]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`_get_embedding_common_attributes()` unconditionally sets `gen_ai.provider.name` to `invocation.provider`, but `EmbeddingInvocation.provider` defaults to `None` and `TelemetryHandler.embedding()` creates an `EmbeddingInvocation()` with provider unset. This makes the embedding finish/error path propagate a `None` attribute value into span/event attribute sets.

### Issue Context
LLM common attributes already treat provider as optional (only include it when non-None). Embedding should behave the same.

### Fix Focus Areas
- util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[73-89]

### Suggested change
Move provider into the `optional_attrs` filtered set (or explicitly guard it) so it is only included when not `None`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Embedding event name diverges 🐞 Bug ✧ Quality
Description
_maybe_emit_embedding_event() emits event_name="gen_ai.client.embedding.operation.details" while
the package documentation and env-var docs describe controlling emission of
gen_ai.client.inference.operation.details events. This inconsistency makes embedding events hard
to discover/consume alongside existing operation-details events.
Code

util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[R258-265]

+    # Create and emit the event
+    context = set_span_in_context(span, get_current())
+    event = LogRecord(
+        event_name="gen_ai.client.embedding.operation.details",
+        attributes=attributes,
+        context=context,
+    )
+    logger.emit(event)
Evidence
Repository docs consistently describe OTEL_INSTRUMENTATION_GENAI_EMIT_EVENT as controlling
gen_ai.client.inference.operation.details, and the LLM event uses that name; embedding uses a
different event name despite its docstring referencing the inference.operation.details semantic
convention.

util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[230-265]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/environment_variables.py[19-26]
util/opentelemetry-util-genai/README.rst[18-23]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Embedding operation-details events are emitted under a different event name than what the package documentation/environment-variable docs describe, creating an inconsistency for users and downstream consumers.

### Issue Context
- Docs/env var describe `gen_ai.client.inference.operation.details`.
- LLM emits `gen_ai.client.inference.operation.details`.
- Embedding emits `gen_ai.client.embedding.operation.details`.

### Fix Focus Areas
- util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[230-265]
- util/opentelemetry-util-genai/src/opentelemetry/util/genai/environment_variables.py[19-26]
- util/opentelemetry-util-genai/README.rst[18-23]

### Suggested change
Pick one:
1) Rename the embedding event to `gen_ai.client.inference.operation.details` (to match docs and existing behavior), or
2) Keep the embedding-specific name but update docs/env-var descriptions (and the function docstring) to reflect the actual emitted name(s).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Empty span name fallback 🐞 Bug ✧ Quality
Description
TelemetryHandler._start() sets span_name = "" for any GenAIInvocation that is not an
LLMInvocation or EmbeddingInvocation. With the new public start() and new GenAIInvocation
subclasses (e.g., WorkflowInvocation, ToolCall), this can create unnamed spans that are
difficult to query and debug.
Code

util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py[R148-158]

+    def _start(self, invocation: _T) -> _T:
+        """Start a GenAI invocation and create a pending span entry."""
+        if isinstance(invocation, LLMInvocation):
+            span_name = _get_llm_span_name(invocation)
+        elif isinstance(invocation, EmbeddingInvocation):
+            span_name = _get_embedding_span_name(invocation)
+        else:
+            span_name = ""
        span = self._tracer.start_span(
-            name=f"{invocation.operation_name} {invocation.request_model}",
+            name=span_name,
            kind=SpanKind.CLIENT,
Evidence
TelemetryHandler.start() accepts a TypeVar bound to GenAIInvocation, but _start() only derives
a name for LLM/Embedding and otherwise uses an empty string. The codebase now defines additional
GenAIInvocation subclasses, and there is already a generic _get_span_name() helper that can
derive a reasonable default from operation_name/request_model.

util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py[148-167]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py[272-287]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py[373-380]
util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[92-98]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`TelemetryHandler._start()` uses an empty span name for invocation types other than LLM/Embedding, even though `TelemetryHandler.start()` is now public/generic and additional `GenAIInvocation` subclasses exist.

### Issue Context
A generic span naming helper (`_get_span_name`) already exists in `span_utils.py` and can derive a default span name from `operation_name`/`request_model`.

### Fix Focus Areas
- util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py[148-158]

### Suggested change
Replace the `else: span_name = ""` branch with a generic naming fallback (e.g., use `_get_span_name(invocation)` or at least `invocation.operation_name` when available).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines +85 to +88
return {
GenAI.GEN_AI_OPERATION_NAME: invocation.operation_name,
GenAI.GEN_AI_PROVIDER_NAME: invocation.provider,
**{key: value for key, value in optional_attrs if value is not None},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. None provider attribute set 🐞 Bug ⛯ Reliability

_get_embedding_common_attributes() always includes gen_ai.provider.name even when
EmbeddingInvocation.provider is None (the default). The new TelemetryHandler.embedding() path
creates EmbeddingInvocation() without a provider, so stop()/fail() can attempt to apply an
attribute with a None value to spans/events.
Agent Prompt
### Issue description
`_get_embedding_common_attributes()` unconditionally sets `gen_ai.provider.name` to `invocation.provider`, but `EmbeddingInvocation.provider` defaults to `None` and `TelemetryHandler.embedding()` creates an `EmbeddingInvocation()` with provider unset. This makes the embedding finish/error path propagate a `None` attribute value into span/event attribute sets.

### Issue Context
LLM common attributes already treat provider as optional (only include it when non-None). Embedding should behave the same.

### Fix Focus Areas
- util/opentelemetry-util-genai/src/opentelemetry/util/genai/span_utils.py[73-89]

### Suggested change
Move provider into the `optional_attrs` filtered set (or explicitly guard it) so it is only included when not `None`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

wrisa and others added 19 commits March 31, 2026 14:14
…metry#4366)

* Add support for workflow invocation in genAI utils handler

* fix changelog

* fixed errors

* addressed comments

* fixed precommit

* made operation name immutable and added test

* removed obsolete test

* removed workflow specific method
* update readme

* Update util/opentelemetry-util-genai/README.rst

Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>

* Update util/opentelemetry-util-genai/README.rst

Co-authored-by: Liudmila Molkova <neskazu@gmail.com>

---------

Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
Co-authored-by: Liudmila Molkova <neskazu@gmail.com>
)

Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…telemetry#4365)

* fix: map Python CRITICAL log level to OTel FATAL severity text in contrib handler

The OTel specification defines the severity text for the highest severity
range as "FATAL", but the contrib logging handler was passing through
Python's native "CRITICAL" level name unchanged. This mirrors the fix
made in open-telemetry/opentelemetry-python#5011 for the SDK handler.

Related: open-telemetry/opentelemetry-python#4984

* Add CHANGELOG entry for CRITICAL -> FATAL severity text mapping

* Update instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/handler.py

---------

Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…pen-telemetry#4110)

* Add _semconv set_db fns

* lint

* Changelog

* semconv opt-in for sqlalchemy instr

* use imports not hardcode

* Update comment on comment-in-attr

* Add tests

* Changelog

* Add migration status

* Sqlalchemy http,database opt-in

* meter schema_url

* Add sqlalchemy _get_db_name_from_cursor

* Add per-signal semconv opt-in schema url precedence; add sqlalchemy usage

* Update _get_db_name coverage

* More db_name_from_cursor cases

* split to lint

* _get_schema parses url from semconv

* _get_* from cursor or conn

* Add _semconv set_db_operation, used by sqlalchemy

* get_db_name safer, update docker-test

* Fix test

* Add schema_url asserts

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…h to ensure file upload works (open-telemetry#4390)

* Add check for if file exists to completion hook

* Add tests

* Add CHANGELOG entry

* Try to delete  file

* Fix linter

* Fix test

* Ignore unknown function..
* tests(aiokafka): bump aiokafka 0.13

* tests(aiokafka): remove removed api_version argument from AIOKafkaProducer

* fix(aiokafka): call serializers directly instead of _serialize

* chore: add CHANGELOG entry for aiokafka 0.13 compatibility fix

* tests(aiokafka): align tests to support python 3.9

* Apply suggestion from @xrmx

---------

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* fix(aiokafka): close AIOKafkaProducer

* fix(aiokafka): use AsyncMock to fix unawaited coroutine warning

* docs(aiokafka): add CHANGELOG entry for test warning fixes

* fix formatting

* Apply suggestion from @xrmx

---------

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…pen-telemetry#4375)

Add is_http_instrumentation_enabled() check in OpenTelemetryMiddleware.__call__
so ASGI server spans are skipped when HTTP instrumentation is suppressed.

Every other HTTP instrumentor (client and server) already honors this flag.
ASGI was the only one that did not.

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* port alls-green to -contrib

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

* fix typo

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>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
…metry#4346)

* wip: wrappers for async message wrappers.

* wip: replacing the invocation response attributes with new attributes function.

* wip: cleaning up the function.

* polish: cleaning up the response attribution using event accumulation method.

* wip: rearranging the code in anthropic wrappers.

* polish: added a changelog.

* wip: fixing lint, typecheck and precommit failures.

* wip: keeping anthropic wrapper same as openai wrapper.

* wip: removing redundant truthy checks for required attributes.
* wip: pydantic based responses api attributes extraction.

* polish: fixing the linting around files.

* refactor: update changelog.

* polish: removing pydantic hard dependency and making pydantic version compatible with openai supported version.

* wip: tox validation for pydantic 1.x version.

* generated new workflows.

* adding the pydantic test to new test file and removing old files.

* wip: generated workflows.

* wip: removed unwanted truthiness checks and simplified the test suite.

* polish: fixed precommit.

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
@shuningc shuningc force-pushed the addingEmbeddingMetric branch from e6216e4 to 68d328f Compare April 8, 2026 00:12
maryliag and others added 3 commits April 8, 2026 16:46
Group all emeritus into one to keep consistent for script cleanup
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.