Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting additional sentry features #358

Open
fgregg opened this issue Jan 24, 2024 · 0 comments
Open

Documenting additional sentry features #358

fgregg opened this issue Jan 24, 2024 · 0 comments
Assignees

Comments

@fgregg
Copy link
Member

fgregg commented Jan 24, 2024

I have been playing around with some sentry features that I've been finding interesting and maybe also useful.

1. performance monitoring

To turn this on for a python project, add a couple of lines to our typical sentry set up

# Configure Sentry for error logging
if os.getenv("SENTRY_DSN"):
    sentry_sdk.init(
        dsn=os.environ["SENTRY_DSN"],
        ...
+       enable_tracing=True,
+       traces_sample_rate=0.05,
    )

enable_tracing turns on performing monitoring and traces_sample_rate set the rate at which sentry will sample events to profile. this shouldn't be too high, or it will use up all of the sentry performance units.

2. releases

Releases are way to tell sentry that errors coming from your app are associated with a particular deployment.

With heroku, this isn't too hard.

First, you have to turn on a setting in heroku to add some metadata about the dyno to the environmental variables of the dyno.

> heroku labs:enable runtime-dyno-metadata -a <app name>

then in your sentry setup:

if os.getenv("SENTRY_DSN"):
    sentry_sdk.init(
        dsn=os.environ["SENTRY_DSN"],
        ...   
+       release=f"{os.environ['HEROKU_RELEASE_VERSION']}-{os.environ['HEROKU_APP_NAME']}",
    )

That's all you have to do, but you can get a few more features if you also add a github action to associate commits with a release. Here is action for chi-councilmatic. You would need to adjust the app name:

https://github.com/datamade/chi-councilmatic/blob/main/.github/workflows/associate_commits.yml

@antidipyramid antidipyramid self-assigned this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants