From 9a4aeced641bd08a2619eb5ac0c31decd8f3744e Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Sat, 17 Jul 2021 15:55:22 +0300 Subject: [PATCH] Add support for Sentry.io --- Retroactiune.WebAPI/Program.cs | 9 +++++++-- Retroactiune.WebAPI/Retroactiune.WebAPI.csproj | 1 + Retroactiune.WebAPI/Startup.cs | 5 +++-- Retroactiune.WebAPI/appsettings.Development.json | 4 ++++ Retroactiune.WebAPI/appsettings.Testing.json | 3 +++ Retroactiune.WebAPI/appsettings.json | 10 ++++++++++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Retroactiune.WebAPI/Program.cs b/Retroactiune.WebAPI/Program.cs index 7605ca0..66eb5f3 100644 --- a/Retroactiune.WebAPI/Program.cs +++ b/Retroactiune.WebAPI/Program.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Hosting; namespace Retroactiune { [ExcludeFromCodeCoverage] + [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] public class Program { public static void Main(string[] args) @@ -12,8 +13,12 @@ namespace Retroactiune CreateHostBuilder(args).Build().Run(); } - public static IHostBuilder CreateHostBuilder(string[] args) => + private static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseSentry(); + webBuilder.UseStartup(); + }); } } \ No newline at end of file diff --git a/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj b/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj index 9f3c7c0..5e6d1d2 100644 --- a/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj +++ b/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj @@ -13,6 +13,7 @@ + diff --git a/Retroactiune.WebAPI/Startup.cs b/Retroactiune.WebAPI/Startup.cs index f79b6b2..2a47f32 100644 --- a/Retroactiune.WebAPI/Startup.cs +++ b/Retroactiune.WebAPI/Startup.cs @@ -13,13 +13,13 @@ using Prometheus; using Retroactiune.Core.Interfaces; using Retroactiune.Core.Services; using Retroactiune.Infrastructure; +using Sentry.AspNetCore; namespace Retroactiune { [ExcludeFromCodeCoverage] public class Startup { - // TODO: Support for Sentry. // TODO: External auth provider. // TODO: UI? public Startup(IConfiguration configuration) @@ -78,7 +78,8 @@ namespace Retroactiune }); app.UseHttpsRedirection(); - + + app.UseSentryTracing(); app.UseRouting(); app.UseAuthorization(); diff --git a/Retroactiune.WebAPI/appsettings.Development.json b/Retroactiune.WebAPI/appsettings.Development.json index 8983e0f..f892137 100644 --- a/Retroactiune.WebAPI/appsettings.Development.json +++ b/Retroactiune.WebAPI/appsettings.Development.json @@ -1,4 +1,8 @@ { + "Sentry": { + "Dsn": "", + "Debug": true + }, "Logging": { "LogLevel": { "Default": "Information", diff --git a/Retroactiune.WebAPI/appsettings.Testing.json b/Retroactiune.WebAPI/appsettings.Testing.json index 7477838..91feb57 100644 --- a/Retroactiune.WebAPI/appsettings.Testing.json +++ b/Retroactiune.WebAPI/appsettings.Testing.json @@ -1,4 +1,7 @@ { + "Sentry": { + "Dsn": "" + }, "DatabaseSettings": { "FeedbacksCollectionName": "feedbacks", "TokensCollectionName": "tokens", diff --git a/Retroactiune.WebAPI/appsettings.json b/Retroactiune.WebAPI/appsettings.json index f698f55..0a87ca2 100644 --- a/Retroactiune.WebAPI/appsettings.json +++ b/Retroactiune.WebAPI/appsettings.json @@ -1,4 +1,14 @@ { + "Sentry": { + "Dsn": "", + "MaxRequestBodySize": "Always", + "SendDefaultPii": true, + "MinimumBreadcrumbLevel": "Debug", + "MinimumEventLevel": "Warning", + "AttachStackTrace": true, + "Debug": false, + "DiagnosticsLevel": "Error" + }, "DatabaseSettings": { "FeedbacksCollectionName": "feedbacks", "TokensCollectionName": "tokens",