* Add fsspec gen ai upload hook
* split up into sub-package to make imports cleaner
* Get rid of FsspecUploader separate class
* comments, clean up doc strings
* Revise codeowners
Drop from codeowners people that have not partecipated in the last year
While at it sort the entries.
* Add entry for util/opentelemetry-util-genai
* botocore: Add support for AWS Step Functions semantic convention attributes
AWS Step Functions defines two semantic convention attributes:
aws.step_functions.activity.arn
aws.step_functions.state_machine.arn
https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-step-functions-attributes
Currently, these attributes are not set in the botocore instrumentation library. This PR adds support for them by extracting values from both Request and Response objects.
Tests
Added new unit tests (passing).
Verified with:
tox -e py312-test-instrumentation-botocore
tox -e spellcheck
tox -e lint-instrumentation-botocore
tox -e ruff
Backward Compatibility
This change is backward compatible. It only adds instrumentation for additional AWS resources and does not modify existing behavior in the auto-instrumentation library.
Note
This PR depends on #3736. Since #3736 has not yet been merged, its changes are included here as well.
* add changelog.
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* botocore: upgrade moto package from 5.0.9 to 5.1.11
Moto 5.0.9, released in May 2024, lacks support for certain AWS resources such as Step Functions APIs. This PR upgrades moto to the latest release (5.1.11) to add these capabilities.
After the upgrade, one DynamoDB unit test failed. This PR also addresses that failure.
The unit test failures after upgrading moto from 5.0.9 to 5.1.11 happened due to two key improvements in moto's DynamoDB implementation:
1. Enhanced Parameter Validation
Before (moto 5.0.9): Moto had lenient validation and allowed invalid parameter combinations like Segment=21 with TotalSegments=17, even though this violates AWS DynamoDB's actual behavior.
After (moto 5.1.11): Moto added stricter validation that matches AWS DynamoDB's real behavior:
Segment parameter must be zero-based (0 to TotalSegments-1)
Segment=21 with TotalSegments=17 now correctly throws ValidationException
2. More Accurate Parallel Scan Simulation
Before (moto 5.0.9): Moto's parallel scan implementation was simplified and might have returned items regardless of which segment was being scanned, leading to predictable but incorrect behavior.
After (moto 5.1.11): Moto improved its parallel scan simulation to more accurately reflect how AWS DynamoDB distributes items across segments:
Items are distributed based on hash values of partition keys
Different segments contain different subsets of data
Segment 16 (out of 17 total) might legitimately contain 0 items if the hash distribution doesn't place any items there
Why This Matters
These changes make moto behave more like the actual AWS DynamoDB service, which is beneficial for testing because:
Tests catch invalid parameter usage that would fail in production
Tests reflect realistic data distribution patterns
Code is validated against more accurate AWS behavior
The test failures weren't bugs in the OpenTelemetry instrumentation code - they were issues with the test setup that became visible when moto started enforcing AWS's actual constraints and behavior patterns.
* add changelog.
* botocore: Add support for SNS semantic convention attribute aws.sns.topic.arn
The AWS SNS semantic convention defines the attribute aws.sns.topic.arn:
https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-sns-attributes
Currently, this attribute is not set in the botocore instrumentation library.
This PR adds support for it by setting the attribute from both the request and response objects.
Tests
New unit tests added and passing.
Verified with:
tox -e py312-test-instrumentation-botocore
tox -e spellcheck
tox -e lint-instrumentation-botocore
tox -e ruff
Backward Compatibility
There is no risk of breaking existing functionality.
This change only adds instrumentation for an additional AWS resource without modifying the existing behavior of the auto-instrumentation library.
* add changelog.
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* opentelemetry-instrumentation: teach opentelemetry-instrument about gevent
Introduce
OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH=patch_all
environment variable that calls gevent monkey module patch_all method
before starting up the distro and sdk. The environment variable should
useful also for apps instrumented via the opentelemetry-operator.
The flag removes the following warning (and hang) when running locust:
$ opentelemetry-instrument locust
/lib/python3.10/site-packages/locust/__init__.py:16: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util (/lib/python3.10/site-packages/urllib3/util/__init__.py)', 'urllib3.util.ssl_ (/lib/python3.10/site-packages/urllib3/util/ssl_.py)'].
monkey.patch_all()
* Update CHANGELOG
* Please pylint
* Apply suggestions from code review
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
* Move environment variable to proper module
---------
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
* rewrite FastAPIInstrumentor:build_middleware_stack to become failsafe
* add test cases for FastAPI failsafe handling
* add CHANGELOG entry
* remove unused import
* [lint] don't return from failsafe wrapper
* [lint] allow broad exceptions
* [lint] more allowing
* record FastAPI hook exceptions in active span
* remove comment
* properly deal with hooks not being set
* add custom FastAPI exception recording
* move failsafe hook handling down to OpenTelemetryMiddleware
* shut up pylint
* optimize failsafe to check for `None` only once
* remove confusing comment and simplify wrapper logic
* add clarifying comment
* test proper exception / status code recording
* add HTTP status code check
* test HTTP status on the exception recording span
* improve test by removing TypeError
* rectify comment/explanation on inner middleware for exception handling
* minor typo
* move ExceptionHandlingMiddleware as the outermost inner middleware
Also improve code documentation and add another test.
* use distinct status code in test
* improve comemnt
Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
* narrow down exception handling
Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
* narrow down FastAPI exception tests to relevant spans
* collapse tests, more narrow exceptions
* move failsafe hook tests to ASGI test suite
* update CHANGELOG
* satisfy linter
* don't record exception if span is not recording
* add test for unhappy instrumentation codepath
* make inject fixtures private
* give up and shut up pylint
* improve instrumentation failure error message and add test
---------
Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
* remote sampling - initial classes and rules poller
* run generate-workflows and ruff
* add component owner for aws sampler, run lint
* move sampler into aws sdk-extensions
* move sampler tests to trace dir, update otel api/sdk deps, update changelog
* move mock_clock into tests dir
* update component owners for sdk-extension-aws
* ruff and lint
* address comments
* make sampler implementation internal until completion, update tests to not make http requests
* remove use of Optional, restore README of the package
* remove unused clock and client_id
* Update component_owners.yml
* Update CHANGELOG.md
---------
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
* Fix tracing of async cursors for psycopg
This copies the traced_execution of AsyncCursorTracer except
query_method is awaited within the span.
Fixes https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2486
* Adding a regression test for asynccursor bug
Adds a test to check that the async tracer is actually awaiting
cursor.execute.
On my machine, with the bug present, the duration is 14000ns. With the
bug patched the the duration is orders of magnitude larger.
* Make return type of query_method an awaitable
* Move implementation to traced_execution_async
---------
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
* Fix git pull error in core contrib test
Core contrib is intermittently failing when
pulling the core repo because tox does not
retry on failure.
Add gh actions/checkout for the core repo
before running tox to mitigate this.
* generate-workflows
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
* Update CHANGELOG.md
---------
Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>