This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Logging/breadcrumb integration with multiple threads #1024
Open
Description
I'm trying to use raven.handlers.logging.SentryHandler
to capture errors and exceptions in my application , but I'm getting some strange behaviour around breadcrumbs that I'm hoping I can get a little help understanding. Potentially this is related to #806 (which @mitsuhiko was looking at), but seeing this behaviour without multiprocessing involved felt like it warranted a new ticket.
MWE:
import raven
import logging
from raven.handlers.logging import SentryHandler
from time import sleep
from threading import Thread
logger = logging.getLogger('foo')
logger.setLevel(logging.DEBUG)
other_logger = logging.getLogger('bar')
other_logger.setLevel(logging.DEBUG)
client = raven.Client()
sentryLogHandler = SentryHandler(client, level="ERROR")
logger.addHandler(sentryLogHandler)
other_logger.addHandler(sentryLogHandler)
sh = logging.StreamHandler()
logger.addHandler(sh)
other_logger.addHandler(sh)
logger.debug("1")
logger.info("2")
other_logger.info("3")
def foo():
other_logger.info("4")
logger.critical("5")
t = Thread(target=foo)
t.start()
sleep(0.1)
logger.critical("6")
Output in the console (via StreamHandler
) is as expected:
1
2
3
4
5
6
However, in Sentry:
- The event for
6
is missing the breadcrumbs for4
and5
(from the other thread), and - The event for
5
has no breadcrumbs at all, not even the4
one from within the same thread.
Any idea what's going on here?