Describe your environment
OS: any
Python version: 3.13, 3.14
Package version: opentelemetry-instrumentation-aiokafka 0.62b0.dev
What happened?
Running the aiokafka instrumentation test suite produces two warnings:
-
ERROR asyncio:base_events.py: Unclosed AIOKafkaProducer intest_send_and_wait. the test creates a producer but never calls producer.stop(), leaving the resource unclosed.
-
RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited in test_wrap_getmany. the _create_consumer_span parameter is typed as mock.MagicMock but the real function is async. When the code calls await _create_consumer_span(...) and then record_span.get_span_context(), the MagicMock auto-creates coroutine return values that are never awaited.
Steps to Reproduce
tox -e py3-test-instrumentation-aiokafka -- -v
Observe the Unclosed AIOKafkaProducer error log during test_send_and_wait
and the RuntimeWarning after the test session completes.
Expected Result
Tests run cleanly with no resource warnings or unawaited coroutine warnings.
Actual Result
ERROR asyncio:base_events.py:1871 Unclosed AIOKafkaProducer
producer: <aiokafka.producer.producer.AIOKafkaProducer object at 0x...>
RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
Additional context
Neither warning causes test failures — all 17 tests pass. These are cosmetic
issues but they add noise to the test output and could mask real warnings.
Would you like to implement a fix?
Yes, PR opened #4384
Describe your environment
OS: any
Python version: 3.13, 3.14
Package version: opentelemetry-instrumentation-aiokafka 0.62b0.dev
What happened?
Running the aiokafka instrumentation test suite produces two warnings:
ERROR asyncio:base_events.py: Unclosed AIOKafkaProducerintest_send_and_wait. the test creates a producer but never callsproducer.stop(), leaving the resource unclosed.RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaitedintest_wrap_getmany. the_create_consumer_spanparameter is typed asmock.MagicMockbut the real function isasync. When the code callsawait _create_consumer_span(...)and thenrecord_span.get_span_context(), the MagicMock auto-creates coroutine return values that are never awaited.Steps to Reproduce
Observe the
Unclosed AIOKafkaProducererror log duringtest_send_and_waitand the
RuntimeWarningafter the test session completes.Expected Result
Tests run cleanly with no resource warnings or unawaited coroutine warnings.
Actual Result
Additional context
Neither warning causes test failures — all 17 tests pass. These are cosmetic
issues but they add noise to the test output and could mask real warnings.
Would you like to implement a fix?
Yes, PR opened #4384