Skip to content

sentry-demos/giraffe

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

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:

  1. Make sure that the latest .NET SDK is installed.
  2. Go into appsettings.json and change the Dsn value to match your own DSN.
  3. Build and run the demo with dotnet run -c Release (or use your IDE).
  4. 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.
  1. Navigate to http://localhost:5000/throw to throw an unhandled exception.
  2. On the sentry.io portal, you should see a new issue reported:

Output on the Sentry portal

  1. You can then inspect that issue in more detail:

Event details 1

Event details 2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages