To show how Sentry works in the ASP.NET Core SDK.
- how to integrate the SDK into ASP.NET CORE (https://docs.sentry.io/platforms/dotnet/aspnetcore/)
- trigger an error that gets sent as Event to Sentry.io Platform
./AspNetCoreMvc/Controllers/HomeController.cs
contains the REST endpoints for triggering errors captured by Sentry SDK and sent as Events to Sentry- The Sentry release cycle is covered in
./AspNetCoreMvc/deploy.ps1
dependency | version |
---|---|
.NET Core Runtime | 3.1.1 |
.NET SDK | 3.1.404 |
Sentry SDK | 2.1.8 |
sentry-cli | 1.62.0 |
PowerShell | 7.1.0 |
macOS | Catalina 10.15.6 |
-
Install dependencies
-
.NET Core Runtime & SDK: https://dotnet.microsoft.com/download/dotnet-core/3.1
-
sentry-sdk:
dotnet add package Sentry.AspNetCore --version 2.1.8
-
Configure your DSN in appsettings.json
-
Configure your org slug and project slug in deploy.ps1
-
Add auth env variable to terminal:
export SENTRY_AUTH_TOKEN=ADD_MY_AUTH_TOKEN_HERE
-
SENTRY_RELEASE=`sentry-cli releases propose-version` pwsh deploy.ps1
-
http://localhost:5001/handled
to trigger error and send event to Sentry
This demo leverages ASP.NET Core's configuration system. Because of this much of your Sentry config info (dsn etc.) is going to be located in appsettings.json
. This allows us to call the UseSentry()
extension method on our webbuilder in Program.cs
without any arguments.
This demo utilizes Sentry's integration with Microsoft.Extensions.Logging
to both set breadcrumbs and send errors. Your appsettings.json
file configures the minimum log levels that correspond to either a crumb or an event. More information here: https://docs.sentry.io/platforms/dotnet/guides/aspnetcore/#configure