Skip to content

Commit 0caca6b

Browse files
committed
Precommit and comment changes
1 parent bcfc20c commit 0caca6b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_shared_internal/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040

4141

4242
class DuplicateFilter(logging.Filter):
43-
"""This prevents logs generated when a log fails to be written to generate another log which fails to be written"""
43+
"""Filter that can be applied to internal `logger`'s.
44+
45+
Currently applied to `logger`s on the export logs path that could otherwise cause endless logging of errors or a
46+
recursion depth exceeded issue in cases where logging itself results in an exception."""
4447

4548
def filter(self, record):
4649
current_log = (

opentelemetry-sdk/tests/shared_internal/test_batch_processor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,12 @@ def test_shutdown_allows_1_export_to_finish(
251251
assert "Exception while exporting" in caplog.text
252252
assert 2 == exporter.num_export_calls
253253

254+
254255
class TestCommonFuncs(unittest.TestCase):
255256
def test_duplicate_logs_filter_works(self):
256257
test_logger = logging.getLogger("testLogger")
257258
test_logger.addFilter(DuplicateFilter())
258259
with self.assertLogs("testLogger") as cm:
259260
test_logger.info("message")
260261
test_logger.info("message")
261-
self.assertEqual(len(cm.output), 1)
262+
self.assertEqual(len(cm.output), 1)

0 commit comments

Comments
 (0)