from sentry_sdk import capture_event, Hub from sentry_sdk.event_manager import EventManager def my_event_handler(event, hint): event_manager = EventManager(hub=Hub.current) event_manager.normalize(event) # further processing or sending to Sentry capture_event(event)
from sentry_sdk import init, capture_exception from sentry_sdk.event_manager import EventManager init(dsn="your-sentry-dsn") try: # some code that may raise an exception except Exception as e: event_manager = EventManager() event_manager.normalize_exception(e) # further processing or sending to Sentry capture_exception(e)In this example, we initialize the Sentry SDK with our DSN and wrap some code in a try-except block to catch any exceptions that may occur. We then create an `EventManager` instance to normalize the exception before sending it to Sentry using `capture_exception`. Overall, the `sentry.sdk` package library for Python provides developers with robust tools for handling and processing errors and exceptions within their Python applications.