-
Notifications
You must be signed in to change notification settings - Fork 759
Description
Describe your environment
Running in a fresh checkout of main, 3f459d3, on Fedora Linux 38, x86_64, with
python3.11 -VV=Python 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]python3.12 -VV=Python 3.12.0b3 (main, Jun 21 2023, 00:00:00) [GCC 13.1.1 20230614 (Red Hat 13.1.1-4)]
This should be platform-independent.
Steps to reproduce
The version pins in dev-requirements.txt cause a lot of problems when trying to test with Python 3.12. We will bypass them all and test without tox.
gh repo clone open-telemetry/opentelemetry-python
cd opentelemetry-python
python3.12 -m venv _e
. _e/bin/activate
cd opentelemetry-semantic-conventions
pip install -e .
cd ../opentelemetry-api
pip install -e .
cd ../opentelemetry-sdk
pip install -e .
cd ../tests/opentelemetry-test-utils/
pip install -e .
cd ../../opentelemetry-sdk
pip install pytest pytest-benchmark flaky
python -m pytest
What is the expected behavior?
If you repeat the above with python3.11 instead of python3.12, or run tox -e py311-opentelemetry-sdk:
(lots of output, DeprecationWarnings, so on)
======================= 377 passed, 9 warnings in 16.09s ========================
What is the actual behavior?
=================================== FAILURES ====================================
______________ TestLoggingHandler.test_log_record_user_attributes _______________
self = <tests.logs.test_handler.TestLoggingHandler testMethod=test_log_record_user_attributes>
def test_log_record_user_attributes(self):
"""Attributes can be injected into logs by adding them to the LogRecord"""
emitter_provider_mock = Mock(spec=LoggerProvider)
emitter_mock = APIGetLogger(
__name__, logger_provider=emitter_provider_mock
)
logger = get_logger(logger_provider=emitter_provider_mock)
# Assert emit gets called for warning message
logger.warning("Warning message", extra={"http.status_code": 200})
args, _ = emitter_mock.emit.call_args_list[0]
log_record = args[0]
self.assertIsNotNone(log_record)
> self.assertEqual(log_record.attributes, {"http.status_code": 200})
E AssertionError: {'taskName': None, 'http.status_code': 200} != {'http.status_code': 200}
E - {'http.status_code': 200, 'taskName': None}
E + {'http.status_code': 200}
tests/logs/test_handler.py:93: AssertionError
------------------------------- Captured log call -------------------------------
WARNING tests.logs.test_handler:test_handler.py:88 Warning message
================== 1 failed, 376 passed, 17 warnings in 16.26s ==================
Additional context
We first encountered this in the Python 3.12 mass rebuild in Fedora Linux in preparation for the release of Fedora 39 this fall. Downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=2220378
I plan to skip this test in the Fedora Linux package for now; I don’t expect to spend more time looking for the root cause.