Skip to content

Commit c9b48cf

Browse files
a-recknagelArne Caratti
authored and
Arne Caratti
committed
exclude invalid attributes, which might also trigger endless logging loops
1 parent b0a5a8d commit c9b48cf

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def _get_attributes(self, record: logging.LogRecord) -> Attributes:
440440
attributes = {
441441
k: v
442442
for k, v in vars(record).items()
443-
if k not in _EXCLUDED_ATTRIBUTES
443+
if k not in _EXCLUDED_ATTRIBUTES and v is not None
444444
}
445445

446446
# Add standard code attributes for logs.

opentelemetry-sdk/tests/logs/test_handler.py

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def test_log_record_user_attributes(self):
114114
log_record = args[0]
115115

116116
self.assertIsNotNone(log_record)
117-
self.assertEqual(len(log_record.attributes), 4)
118117
self.assertEqual(
119118
log_record.attributes,
120119
{**log_record.attributes, **{"http.status_code": 200}},

0 commit comments

Comments
 (0)