Sentry has various configuration options to help enhance the SDK functionality. The options can help provide additional data needed to debug issues even faster or help control what is sent to Sentry by filtering. For more information, see Configuration.
release is a version of your code that is deployed to an environment. Configuring the Release helps you figure out if there is a regression in your code, hold accountability, resolve issues within Sentry, and staying up to date with your deployments. Releases need to be configured within your SDK and then managed through the sentry-cli to support extra features such as suspect commits and suggested assignee.
Sentry currently supports integrations with GitHub, BitBucket, Azure DevOps, GitLab, and others. For a complete list of our integrations, check out our docs on Integrations.
Let's see how we set up the release in this project:
Open the file
settings.py. Notice that we add the
releaseconfiguration option when initializing the SDK.Copied
Makefileyou ran in the previous tutorial.
Notice that we're settings the release version name as an environment variable that is then used in the application's runtime. We're letting the CLI propose a release version name, but you'd probably want to apply your naming conventions:Copied
VERSION=`sentry-cli releases propose-version`
Then we create the new release for our project with the proposed/selected nameCopied
> create_release: sentry-cli releases -o $(SENTRY_ORG) new -p $(SENTRY_PROJECT) $(VERSION)
In the previous tutorial, we configured the GitHub integration and added the code repository for Commit Tracking. Now we can associate commits from that repository to the new release, by running the command:Copied
> associate_commits: sentry-cli releases -o $(SENTRY_ORG) -p $(SENTRY_PROJECT) \ set-commits $(VERSION) --auto
Breadcrumbs are the trail of events that led up to the error. They can be quite useful when trying to reproduce an issue. Depending on the platform, the SDK will track various types of Breadcrumbs by default (for backend SDKs those are DB queries, Network events, Logging, and others) and you can add custom breadcrumbs as well.
Let's see how we add breadcrumbs to our app:
Open the file
myapp > view.py
Notice we import
add_breadcrumbfrom the SDK lib.Copied
from sentry_sdk import add_breadcrumb
We create a custom breadcrumb for each method handler in the view classes. This breadcrumb will be added to the trail of breadcrumbs associated with any error triggered through these method call flows. For instance, under
add_breadcrumb( category='URL Endpoints', message='In the handled function', level='info', )
Environment is a powerful configuration option that enables developers using Sentry to perform various workflows (filter issues, trigger alerts, etc.) in the context of the deployment environment in which the errors occurred in.
Notice that we initialize the SDK with the
environmentconfiguration option. Any event that will be captured by the SDK will be tagged with the configured environment value.Copied
Note: Environment values are freeform strings. The Sentry SDK or UI will not limit you to any specific value or format. In this example, we hardcoded the value. In a real-life app, the value would probably be determined dynamically through a properties file, system, or environment variable.