Add support for Sentry.io

This commit is contained in:
Denis-Cosmin Nutiu 2021-07-17 15:55:22 +03:00
parent 48124346c0
commit 9a4aeced64
6 changed files with 28 additions and 4 deletions

View file

@ -5,6 +5,7 @@ using Microsoft.Extensions.Hosting;
namespace Retroactiune namespace Retroactiune
{ {
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
public class Program public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
@ -12,8 +13,12 @@ namespace Retroactiune
CreateHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) => private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); .ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseSentry();
webBuilder.UseStartup<Startup>();
});
} }
} }

View file

@ -13,6 +13,7 @@
<PackageReference Include="MongoDB.Driver" Version="2.12.3" /> <PackageReference Include="MongoDB.Driver" Version="2.12.3" />
<PackageReference Include="prometheus-net" Version="4.2.0" /> <PackageReference Include="prometheus-net" Version="4.2.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="4.2.0" /> <PackageReference Include="prometheus-net.AspNetCore" Version="4.2.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup> </ItemGroup>

View file

@ -13,13 +13,13 @@ using Prometheus;
using Retroactiune.Core.Interfaces; using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services; using Retroactiune.Core.Services;
using Retroactiune.Infrastructure; using Retroactiune.Infrastructure;
using Sentry.AspNetCore;
namespace Retroactiune namespace Retroactiune
{ {
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public class Startup public class Startup
{ {
// TODO: Support for Sentry.
// TODO: External auth provider. // TODO: External auth provider.
// TODO: UI? // TODO: UI?
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
@ -78,7 +78,8 @@ namespace Retroactiune
}); });
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseSentryTracing();
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();

View file

@ -1,4 +1,8 @@
{ {
"Sentry": {
"Dsn": "",
"Debug": true
},
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",

View file

@ -1,4 +1,7 @@
{ {
"Sentry": {
"Dsn": ""
},
"DatabaseSettings": { "DatabaseSettings": {
"FeedbacksCollectionName": "feedbacks", "FeedbacksCollectionName": "feedbacks",
"TokensCollectionName": "tokens", "TokensCollectionName": "tokens",

View file

@ -1,4 +1,14 @@
{ {
"Sentry": {
"Dsn": "",
"MaxRequestBodySize": "Always",
"SendDefaultPii": true,
"MinimumBreadcrumbLevel": "Debug",
"MinimumEventLevel": "Warning",
"AttachStackTrace": true,
"Debug": false,
"DiagnosticsLevel": "Error"
},
"DatabaseSettings": { "DatabaseSettings": {
"FeedbacksCollectionName": "feedbacks", "FeedbacksCollectionName": "feedbacks",
"TokensCollectionName": "tokens", "TokensCollectionName": "tokens",