This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
instrumentation/opentelemetry-instrumentation-asyncio
src/opentelemetry/instrumentation/asyncio Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## Version 1.25.0/0.46b0+asyncio-wait-for-fix (2024-06-26)
9+
10+ ### Fixed
11+
12+ - ` opentelemetry-instrumentation-asyncio ` instrumented ` asyncio.wait_for ` properly raises ` asyncio.TimeoutError ` as expected
13+ ([ #2637 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2637 ) )
14+
815## Version 1.25.0/0.46b0 (2024-05-30)
916
1017### Breaking changes
Original file line number Diff line number Diff line change @@ -280,8 +280,11 @@ async def trace_coroutine(self, coro):
280280 # CancelledError is raised when a coroutine is cancelled
281281 # before it has a chance to run. We don't want to record
282282 # this as an error.
283+ # Still it needs to be raised in order for `asyncio.wait_for`
284+ # to properly work with timeout and raise accordingly `asyncio.TimeoutError`
283285 except asyncio .CancelledError :
284286 attr ["state" ] = "cancelled"
287+ raise
285288 except Exception as exc :
286289 exception = exc
287290 state = determine_state (exception )
Original file line number Diff line number Diff line change @@ -68,6 +68,19 @@ async def main():
6868 spans = self .memory_exporter .get_finished_spans ()
6969 self .assertEqual (len (spans ), 2 )
7070
71+ def test_asyncio_wait_for_with_timeout (self ):
72+ expected_timeout_error = None
73+
74+ async def main ():
75+ nonlocal expected_timeout_error
76+ try :
77+ await asyncio .wait_for (async_func (), 0.01 )
78+ except asyncio .TimeoutError as timeout_error :
79+ expected_timeout_error = timeout_error
80+
81+ asyncio .run (main ())
82+ self .assertNotEqual (expected_timeout_error , None )
83+
7184 def test_asyncio_as_completed (self ):
7285 async def main ():
7386 if sys .version_info >= (3 , 11 ):
You can’t perform that action at this time.
0 commit comments