/sentry-python

The official Python SDK for Sentry.io

Primary LanguagePythonMIT LicenseMIT

Sentry for Python

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us, check out our open positions.

Official Sentry SDK for Python

Build Status PyPi page link -- version Discord

Welcome to the official Python SDK for Sentry!

Getting Started

Installation

Getting Sentry into your project is straightforward. Just run this command in your terminal:

pip install --upgrade sentry-sdk

Basic Configuration

Here’s a quick configuration example to get Sentry up and running:

import sentry_sdk

sentry_sdk.init(
    "https://12927b5f211046b575ee51fd8b1ac34f@o1.ingest.sentry.io/1",  # Your DSN here

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    traces_sample_rate=1.0,
)

With this configuration, Sentry will monitor for exceptions and performance issues.

Quick Usage Example

To generate some events that will show up in Sentry, you can log messages or capture errors:

from sentry_sdk import capture_message
capture_message("Hello Sentry!")  # You'll see this in your Sentry dashboard.

raise ValueError("Oops, something went wrong!")  # This will create an error event in Sentry.

Explore the Docs

For more details on advanced usage, integrations, and customization, check out the full documentation:

Integrations

Sentry integrates with many popular Python libraries and frameworks, including:

Want more? Check out the full list of integrations.

Rolling Your Own Integration?

If you want to create a new integration or improve an existing one, we’d welcome your contributions! Please read our contributing guide before starting.

Migrating Between Versions?

From 1.x to 2.x

If you're using the older 1.x version of the SDK, now's the time to upgrade to 2.x. It includes significant upgrades and new features. Check our migration guide for assistance.

From raven-python

Using the legacy raven-python client? It's now in maintenance mode, and we recommend migrating to the new SDK for an improved experience. Get all the details in our migration guide.

Want to Contribute?

We’d love your help in improving the Sentry SDK! Whether it’s fixing bugs, adding features, or enhancing documentation, every contribution is valuable.

For details on how to contribute, please check out CONTRIBUTING.md and explore the open issues.

Need Help?

If you encounter issues or need help setting up or configuring the SDK, don’t hesitate to reach out to the Sentry Community on Discord. There is a ton of great people there ready to help!

Resources

Here are additional resources to help you make the most of Sentry:

  • Documentation – Official documentation to get started.
  • Discord – Join our Discord community.
  • Twitter Follow – Follow us on X (Twitter) for updates.
  • Stack Overflow – Questions and answers related to Sentry.

License

The SDK is open-source and available under the MIT license. Check out the LICENSE file for more information.


Thanks to everyone who has helped improve the SDK!