Skip to content

Commit

Permalink
add different msg types tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GanymedeNil committed Jun 15, 2023
1 parent 4595953 commit eef7ea1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions opentelemetry-sdk/tests/logs/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,40 @@ def test_simple_log_record_processor_shutdown(self):
finished_logs = exporter.get_finished_logs()
self.assertEqual(len(finished_logs), 0)

def test_simple_log_record_processor_different_msg_types(self):
exporter = InMemoryLogExporter()
log_record_processor = BatchLogRecordProcessor(exporter)

provider = LoggerProvider()
provider.add_log_record_processor(log_record_processor)

logger = logging.getLogger("different_msg_types")
logger.addHandler(LoggingHandler(logger_provider=provider))

logger.warning("warning message: %s", "possible upcoming heatwave")
logger.error("Very high rise in temperatures across the globe")
logger.critical("Temperature hits high 420 C in Hyderabad")
logger.warning(["list", "of", "strings"])
logger.error({"key": "value"})
log_record_processor.shutdown()

finished_logs = exporter.get_finished_logs()
expected = [
("warning message: possible upcoming heatwave", "WARNING"),
("Very high rise in temperatures across the globe", "ERROR"),
(
"Temperature hits high 420 C in Hyderabad",
"CRITICAL",
),
(["list", "of", "strings"], "WARNING"),
({"key": "value"}, "ERROR")
]
emitted = [
(item.log_record.body, item.log_record.severity_text)
for item in finished_logs
]
self.assertEqual(expected, emitted)


class TestBatchLogRecordProcessor(ConcurrencyTestBase):
def test_emit_call_log_record(self):
Expand Down

0 comments on commit eef7ea1

Please sign in to comment.