Skip to content

Commit

Permalink
Tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nstawski committed Oct 9, 2024
1 parent b5daf85 commit 171087f
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions opentelemetry-sdk/tests/logs/test_log_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,18 @@ def test_log_record_dropped_attributes_set_limits_max_attribute(self):
max_attributes=1,
)

result = LogRecord(
timestamp=0, body="a log line", attributes=attr, limits=limits
)
with warnings.catch_warnings(record=True) as cw:
warnings.simplefilter("always")
result = LogRecord(
timestamp=0, body="a log line", attributes=attr, limits=limits
)

self.assertTrue(
any(
issubclass(warning.category, LogDroppedAttributesWarning)
for warning in cw
)
)
self.assertTrue(result.dropped_attributes == 1)

def test_log_record_dropped_attributes_set_limits_max_attribute_length(
Expand All @@ -93,9 +102,18 @@ def test_log_record_dropped_attributes_set_limits_max_attribute_length(
max_attribute_length=1,
)

result = LogRecord(
timestamp=0, body="a log line", attributes=attr, limits=limits
)
with warnings.catch_warnings(record=True) as cw:
warnings.simplefilter("always")
result = LogRecord(
timestamp=0, body="a log line", attributes=attr, limits=limits
)
# would not be dropping any attributes if the limit is not set
self.assertFalse(
any(
issubclass(warning.category, LogDroppedAttributesWarning)
for warning in cw
)
)
self.assertTrue(result.dropped_attributes == 0)
self.assertEqual(expected, result.attributes)

Expand Down

0 comments on commit 171087f

Please sign in to comment.