Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 64 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,111 +2,127 @@
<img src="https://sentry-brand.storage.googleapis.com/github-banners/github-sdk-python.png" alt="Sentry for Python">
</a>

_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, [<kbd>**check out our open positions**</kbd>](https://sentry.io/careers/)_.
Bad software is everywhere, and developers often deal with bugs that crash systems at the worst possible moments. Enter **Sentry**: our mission is to help developers write better software faster, so you can focus on building.

# Official Sentry SDK for Python

[![Build Status](https://github.com/getsentry/sentry-python/actions/workflows/ci.yml/badge.svg)](https://github.com/getsentry/sentry-python/actions/workflows/ci.yml)
[![PyPi page link -- version](https://img.shields.io/pypi/v/sentry-sdk.svg)](https://pypi.python.org/pypi/sentry-sdk)
[![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/cWnMQeA)

This is the official Python SDK for [Sentry](http://sentry.io/)
Welcome to the official Python SDK for **[Sentry](http://sentry.io/)**! If you care about tracking down every error and performance bottleneck in your app, you're in the right place.

## Getting Started

### Install
### Installation

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

```bash
pip install --upgrade sentry-sdk
```

### Configuration
### Basic Configuration

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

```python
import sentry_sdk

sentry_sdk.init(
"https://[email protected]/1",
"https://[email protected]/1", # Your DSN here

# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
traces_sample_rate=1.0, # Adjust this based on your performance needs
)
```

### Usage
With this configuration, Sentry will monitor for exceptions and performance issues in the background while you continue coding. Adjust the `traces_sample_rate` to fine-tune performance monitoring.

### Quick Usage Example

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

```python
from sentry_sdk import capture_message
capture_message("Hello World") # Will create an event in Sentry.
capture_message("Hello Sentry!") # You'll see this in your Sentry dashboard.

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

- To learn more about how to use the SDK [refer to our docs](https://docs.sentry.io/platforms/python/).
- Are you coming from `raven-python`? [Use this migration guide](https://docs.sentry.io/platforms/python/migration/).
- To learn about internals use the [API Reference](https://getsentry.github.io/sentry-python/).
#### Explore the Docs

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

- [Official SDK Docs](https://docs.sentry.io/platforms/python/)
- [API Reference](https://getsentry.github.io/sentry-python/)

### Migrating from `raven-python`?
If you’re still using `raven-python`, migrating to the new Sentry SDK is smooth. [Check out this guide](https://docs.sentry.io/platforms/python/migration/) for details.

## Integrations

(If you want to create a new integration, have a look at the [Adding a new integration checklist](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md#adding-a-new-integration).)
Sentry integrates with several popular Python libraries and frameworks, including:

- [Django](https://docs.sentry.io/platforms/python/integrations/django/) – Full support for error and performance tracking.
- [Flask](https://docs.sentry.io/platforms/python/integrations/flask/) – Flask-specific error handling.
- [FastAPI](https://docs.sentry.io/platforms/python/integrations/fastapi/) – FastAPI support.
- [Celery](https://docs.sentry.io/platforms/python/integrations/celery/) – Monitoring distributed tasks.
- [AWS Lambda](https://docs.sentry.io/platforms/python/integrations/aws-lambda/) – Support for serverless applications.

Want more? [Check out the full list of integrations](https://docs.sentry.io/platforms/python/integrations/).

See [the documentation](https://docs.sentry.io/platforms/python/integrations/) for an up-to-date list of libraries and frameworks we support. Here are some examples:
### Rolling Your Own Integration?

- [Django](https://docs.sentry.io/platforms/python/integrations/django/)
- [Flask](https://docs.sentry.io/platforms/python/integrations/flask/)
- [FastAPI](https://docs.sentry.io/platforms/python/integrations/fastapi/)
- [AIOHTTP](https://docs.sentry.io/platforms/python/integrations/aiohttp/)
- [SQLAlchemy](https://docs.sentry.io/platforms/python/integrations/sqlalchemy/)
- [asyncpg](https://docs.sentry.io/platforms/python/integrations/asyncpg/)
- [Redis](https://docs.sentry.io/platforms/python/integrations/redis/)
- [Celery](https://docs.sentry.io/platforms/python/integrations/celery/)
- [Apache Airflow](https://docs.sentry.io/platforms/python/integrations/airflow/)
- [Apache Spark](https://docs.sentry.io/platforms/python/integrations/pyspark/)
- [asyncio](https://docs.sentry.io/platforms/python/integrations/asyncio/)
- [Graphene](https://docs.sentry.io/platforms/python/integrations/graphene/)
- [Logging](https://docs.sentry.io/platforms/python/integrations/logging/)
- [Loguru](https://docs.sentry.io/platforms/python/integrations/loguru/)
- [HTTPX](https://docs.sentry.io/platforms/python/integrations/httpx/)
- [AWS Lambda](https://docs.sentry.io/platforms/python/integrations/aws-lambda/)
- [Google Cloud Functions](https://docs.sentry.io/platforms/python/integrations/gcp-functions/)
If you want to create a new integration or improve an existing one, we’d welcome your contributions! Please read our [contributing guide](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md) before starting.

## Migrating Between Versions?

## Migrating
### From `1.x` to `2.x`

### Migrating 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](https://docs.sentry.io/platforms/python/migration/1.x-to-2.x) for assistance.

If you're on SDK version 1.x, we highly recommend updating to the 2.x major. To make the process easier we've prepared a [migration guide](https://docs.sentry.io/platforms/python/migration/1.x-to-2.x) with the most common changes as well as a [detailed changelog](MIGRATION_GUIDE.md).
### From `raven-python`

### Migrating 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](https://docs.sentry.io/platforms/python/migration/raven-to-sentry-sdk/).

The old `raven-python` client has entered maintenance mode and was moved [here](https://github.com/getsentry/raven-python).
## Want to Contribute?

If you're using `raven-python`, we recommend you to migrate to this new SDK. You can find the benefits of migrating and how to do it in our [migration guide](https://docs.sentry.io/platforms/python/migration/raven-to-sentry-sdk/).
We’d love your help in improving the Sentry SDK! Whether it’s fixing bugs, adding features, or enhancing documentation, every contribution is valuable.

## Contributing to the SDK
For details on how to contribute, please check out [CONTRIBUTING.md](CONTRIBUTING.md) and explore the [open issues](https://github.com/getsentry/sentry-python/issues).

Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
## Need Help?

## Getting Help/Support
If you encounter issues, don’t hesitate to reach out to our community for support:

If you need help setting up or configuring the Python SDK (or anything else in the Sentry universe) please head over to the [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you!
- **[Sentry Discord Community](https://discord.com/invite/Ww9hbqr)** – A helpful community is ready to assist.
- **[Stack Overflow](http://stackoverflow.com/questions/tagged/sentry)** – A great place for asking questions.
- **[Sentry Forum](https://forum.sentry.io/c/sdks)** – Share ideas and get advice.

## Resources

- [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/quickstart/)
- [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
- [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
- [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)
- [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
Here are additional resources to help you make the most of Sentry:

- [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/quickstart/) – Official documentation to get started.
- [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks) – Forums for in-depth discussions.
- [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry) – Ask questions here.
- [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr) – Join our Discord community.
- [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry) – Follow us on Twitter for updates.

## License

Licensed under the MIT license, see [`LICENSE`](LICENSE)
The SDK is open-source and available under the MIT license. Check out the [LICENSE](LICENSE) file for more information.

---

### Thanks to all the people who contributed!
Thanks to all the contributors who have made the Sentry Python SDK great!

<a href="https://github.com/getsentry/sentry-python/graphs/contributors">
<img src="https://contributors-img.web.app/image?repo=getsentry/sentry-python" />
</a>

---

Keep writing better code and let Sentry handle the errors.
Loading