From c9b48cffbc93472d226f1835314a503ae6ea506e Mon Sep 17 00:00:00 2001 From: Arne Caratti Date: Fri, 16 Feb 2024 11:21:12 +0100 Subject: [PATCH] exclude invalid attributes, which might also trigger endless logging loops --- .../src/opentelemetry/sdk/_logs/_internal/__init__.py | 2 +- opentelemetry-sdk/tests/logs/test_handler.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py index 22cf273c6d7..0e85b464c33 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py @@ -440,7 +440,7 @@ def _get_attributes(self, record: logging.LogRecord) -> Attributes: attributes = { k: v for k, v in vars(record).items() - if k not in _EXCLUDED_ATTRIBUTES + if k not in _EXCLUDED_ATTRIBUTES and v is not None } # Add standard code attributes for logs. diff --git a/opentelemetry-sdk/tests/logs/test_handler.py b/opentelemetry-sdk/tests/logs/test_handler.py index 079aae2b466..2bd82efd464 100644 --- a/opentelemetry-sdk/tests/logs/test_handler.py +++ b/opentelemetry-sdk/tests/logs/test_handler.py @@ -114,7 +114,6 @@ def test_log_record_user_attributes(self): log_record = args[0] self.assertIsNotNone(log_record) - self.assertEqual(len(log_record.attributes), 4) self.assertEqual( log_record.attributes, {**log_record.attributes, **{"http.status_code": 200}},