Sentry with loggingIntegration in python not observing event_level=logging.CRITICAL

26 Views Asked by At

I have a python script that initialises sentry like so:

def sentry_init():
    sentry_sdk.init(
        'some dsn',
        traces_sample_rate=1.0,
        environment='staging',
        integrations=[
            LoggingIntegration(
                level=logging.INFO,  # Capture info and above as breadcrumbs
                event_level=logging.CRITICAL,  # Send records as events
            ),
        ],
    )

def foo():
    # calls functions from another script which also logs

if __name__ == "__main__":
   
    sentry_init()
    logging.basicConfig(level='INFO')
    log = logging.getLogger('foo')
    log.addHandler(HttpApiHandler())
    foo()

in another module called modb which has functions called from foo() I also have logging setup with log = logging.getLogger(__name__)

# modb
import logging
log = logging.getLogger(__name__)

def modfunc():
    try:
        if:
            # Some conditions
        else:
            raise Exception("Some error")
    except Exception as e:
         log.error(str(e))

so modb has a catchall which is handled by logging an ERROR. But I am seeing this ERROR logged in sentry. How is this possible if I initialised sentry to only log CRITICAL or above ?

This problem is not occuring when an ERROR is thrown from within the main module its only happening from sub modules called from the main one.

0

There are 0 best solutions below