How to clear breadcrumbs (Python SDK)

I have an Azure Function in Python. There’s no Sentry integration for this framework so I’m just use sentry_sdk and it’s working great.
The problem is that I get breadcrumbs from past executions of the function in each event. I see the JSON has 100 items in the breadcrumbs array so I’m guessing it’s limiting all of them.

My guess’s, because of the way Azure Functions are executed, that sentry_sdk thinks that all the executions belongs to the same “session”. I tried creating a new logger on every execution of my function but it didn’t work.

def main(msg: func.QueueMessage) -> None:
    logger = logging.getLogger(__name__)

    sentry_sdk.init()

    with sentry_sdk.configure_scope() as scope:
        scope.set_tag("queue_message_id", msg.id)

    logger.info("This is being captured properly on each error, but it's also including previous runs logs")

How can I force a reset on this when doing sentry_sdk.init() or maybe clearing the breadcrumbs stored so far?

I would recommend decorating your functions with the
serverless_function decorator:
https://docs.sentry.io/platforms/python/serverless/. This should
prevent scope tags bleeding across function calls and also makes sure
events go out before your app is killed.

To clear breadcrumbs, call scope.clear_breadcrumbs()

Great! Adding the serverless decorator did the trick. No need to call scope.clear_breadcrumbs()

Thanks!