Sentry Giraffe F# Demo
This is an example Giraffe web application that demonstrates how to integrate Sentry for error reporting.
- To install Sentry's ASP.NET Core integration, you can use NuGet:
dotnet add package Sentry.AspNetCore
...or Paket:
paket add Sentry.AspNetCore
...or add it directly into your .fsproj
file:
<PackageReference Include="Sentry.AspNetCore" Version="3.0.0" />
- In order to integrate with Sentry, simply add a call to
UseSentry()
when setting up the web host:
[<EntryPoint>]
let main _ =
WebHost.CreateDefaultBuilder()
.ConfigureServices(configureServices)
.Configure(configureApp)
.UseSentry()
.Build()
.Run()
0
The example in Program.fs
showcases how Sentry can automatically catch and report unhandled exceptions and also how you can enrich sent data with additional information.
For an F# example that goes more in-depth in the Sentry SDK's API, please check out the base F# demo.
Running the demo
To run the demo, take the following steps:
- Make sure that the latest .NET SDK is installed.
- Go into
appsettings.json
and change theDsn
value to match your own DSN. - Build and run the demo with
dotnet run -c Release
(or use your IDE). - You should see the following debug output in the console:
Hosting environment: Production
Content root path: E:\Projects\Softdev\!Work\sentry-demos-giraffe
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
- Navigate to
http://localhost:5000/throw
to throw an unhandled exception. - On the sentry.io portal, you should see a new issue reported:
- You can then inspect that issue in more detail: