opentelemetry-python-contrib
opentelemetry-python-contrib copied to clipboard
fix(tornado): ensure reading future.result() won't throw an exception in client.py _finish_tracing_callback
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes #2555
Ensures correct handling of an exception future result from tornado http client. Before this change, an exception result would cause an exception to be raised that is not handled by the lib - which is undesired based on logic in client.py _finish_tracing_callback.
Type of change
Please delete options that are not relevant.
- [X] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [X] With tornado instrumentation enabled, use tornado http client fetch with option
raise_error=Trueand make a request that fails (response of 404, 500, etc...). An exception in _finish_tracing_callback will be raised that is not handled above - bubbles up to the asyncio runtime. - [X] Unit test added to verify traced http client request failure has its span exported (indirectly verifies that _finish_tracing_callback completes successfully).
Note: The new test class
class TestTornadoHTTPClientInstrumentationcan be copied to main branch, andtest_http_client_failed_responsewill fail due to this bug.
Does This PR Require a Core Repo Change?
- [X] No.
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
- [X] Followed the style guidelines of this project
- [x] Changelogs have been updated
- [X] Unit tests have been added
- [x] Documentation has been updated