File tree 3 files changed +18
-0
lines changed
instrumentation/opentelemetry-instrumentation-asyncio
src/opentelemetry/instrumentation/asyncio
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## Unreleased
9
9
10
+ - ` opentelemetry-instrumentation-asyncio ` instrumented ` asyncio.wait_for ` properly raises ` asyncio.TimeoutError ` as expected
11
+ ([ #2637 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2637 ) )
10
12
- ` opentelemetry-instrumentation-aws-lambda ` Bugfix: AWS Lambda event source key incorrect for SNS in instrumentation library.
11
13
([ #2612 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2612 ) )
12
14
- ` opentelemetry-instrumentation-system-metrics ` Permit to use psutil 6.0+.
Original file line number Diff line number Diff line change @@ -280,8 +280,11 @@ async def trace_coroutine(self, coro):
280
280
# CancelledError is raised when a coroutine is cancelled
281
281
# before it has a chance to run. We don't want to record
282
282
# 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`
283
285
except asyncio .CancelledError :
284
286
attr ["state" ] = "cancelled"
287
+ raise
285
288
except Exception as exc :
286
289
exception = exc
287
290
state = determine_state (exception )
Original file line number Diff line number Diff line change @@ -68,6 +68,19 @@ async def main():
68
68
spans = self .memory_exporter .get_finished_spans ()
69
69
self .assertEqual (len (spans ), 2 )
70
70
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
+
71
84
def test_asyncio_as_completed (self ):
72
85
async def main ():
73
86
if sys .version_info >= (3 , 11 ):
You can’t perform that action at this time.
0 commit comments