Skip to content

Sentry won't work properly with typer #1604

@birdhackor

Description

@birdhackor

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.9.8

Steps to Reproduce

I try to use sentry with typer.

Seems sentry will not catch uphandled exception with them.

With typer method 1:

import typer
import sentry_sdk

sentry_sdk.init(
    dsn="dsn",
    debug=True,

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production.
    traces_sample_rate=1.0
)

def main():
    1/0

if __name__ == "__main__":
    typer.run(main)

With typer method 2:

import typer
import sentry_sdk

sentry_sdk.init(
    dsn="dsn",
    debug=True,

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production.
    traces_sample_rate=1.0
)

def main():
    1/0

if __name__ == "__main__":
    try:
        typer.run(main)
    except:
        print('YES, we enter exception handling block')
        raise

Both way don't work

Expected Result

Seems sentry should record error in both way.

Actual Result

Seems sentry don't record error in either way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    New IntegrationIntegrating with a new framework or libraryTriagedHas been looked at recently during old issue triage

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions