Browse Source

add error reporting health check (#667)

pull/669/head
Jason Dove 4 years ago committed by GitHub
parent
commit
24ef5e68eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      ErsatzTV.Core/Health/Checks/IErrorReportsHealthCheck.cs
  2. 33
      ErsatzTV.Infrastructure/Health/Checks/ErrorReportsHealthCheck.cs
  3. 6
      ErsatzTV.Infrastructure/Health/HealthCheckService.cs
  4. 2
      ErsatzTV/Startup.cs

5
ErsatzTV.Core/Health/Checks/IErrorReportsHealthCheck.cs

@ -0,0 +1,5 @@
namespace ErsatzTV.Core.Health.Checks;
public interface IErrorReportsHealthCheck : IHealthCheck
{
}

33
ErsatzTV.Infrastructure/Health/Checks/ErrorReportsHealthCheck.cs

@ -0,0 +1,33 @@
using System.Threading.Tasks;
using ErsatzTV.Core.Errors;
using ErsatzTV.Core.Health;
using ErsatzTV.Core.Health.Checks;
using LanguageExt;
using Microsoft.Extensions.Options;
namespace ErsatzTV.Infrastructure.Health.Checks;
public class ErrorReportsHealthCheck : BaseHealthCheck, IErrorReportsHealthCheck
{
private readonly IOptions<BugsnagConfiguration> _bugsnagConfiguration;
public ErrorReportsHealthCheck(IOptions<BugsnagConfiguration> bugsnagConfiguration)
{
_bugsnagConfiguration = bugsnagConfiguration;
}
protected override string Title => "Error Reports";
public Task<HealthCheckResult> Check()
{
if (_bugsnagConfiguration.Value.Enable)
{
return Result(
HealthCheckStatus.Pass,
"Automated error reporting is enabled, thank you! To disable, edit the file appsettings.json or set the Bugsnag:Enable environment variable to false")
.AsTask();
}
return InfoResult("Automated error reporting is disabled. Please enable to support bug fixing efforts!").AsTask();
}
}

6
ErsatzTV.Infrastructure/Health/HealthCheckService.cs

@ -20,7 +20,8 @@ namespace ErsatzTV.Infrastructure.Health
IEpisodeMetadataHealthCheck episodeMetadataHealthCheck, IEpisodeMetadataHealthCheck episodeMetadataHealthCheck,
IZeroDurationHealthCheck zeroDurationHealthCheck, IZeroDurationHealthCheck zeroDurationHealthCheck,
IFileNotFoundHealthCheck fileNotFoundHealthCheck, IFileNotFoundHealthCheck fileNotFoundHealthCheck,
IVaapiDriverHealthCheck vaapiDriverHealthCheck) IVaapiDriverHealthCheck vaapiDriverHealthCheck,
IErrorReportsHealthCheck errorReportsHealthCheck)
{ {
_checks = new List<IHealthCheck> _checks = new List<IHealthCheck>
{ {
@ -31,7 +32,8 @@ namespace ErsatzTV.Infrastructure.Health
episodeMetadataHealthCheck, episodeMetadataHealthCheck,
zeroDurationHealthCheck, zeroDurationHealthCheck,
fileNotFoundHealthCheck, fileNotFoundHealthCheck,
vaapiDriverHealthCheck vaapiDriverHealthCheck,
errorReportsHealthCheck
}; };
} }

2
ErsatzTV/Startup.cs

@ -83,6 +83,7 @@ namespace ErsatzTV
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
BugsnagConfiguration bugsnagConfig = Configuration.GetSection("Bugsnag").Get<BugsnagConfiguration>(); BugsnagConfiguration bugsnagConfig = Configuration.GetSection("Bugsnag").Get<BugsnagConfiguration>();
services.Configure<BugsnagConfiguration>(Configuration.GetSection("Bugsnag"));
services.AddBugsnag( services.AddBugsnag(
configuration => configuration =>
@ -288,6 +289,7 @@ namespace ErsatzTV
services.AddScoped<IZeroDurationHealthCheck, ZeroDurationHealthCheck>(); services.AddScoped<IZeroDurationHealthCheck, ZeroDurationHealthCheck>();
services.AddScoped<IFileNotFoundHealthCheck, FileNotFoundHealthCheck>(); services.AddScoped<IFileNotFoundHealthCheck, FileNotFoundHealthCheck>();
services.AddScoped<IVaapiDriverHealthCheck, VaapiDriverHealthCheck>(); services.AddScoped<IVaapiDriverHealthCheck, VaapiDriverHealthCheck>();
services.AddScoped<IErrorReportsHealthCheck, ErrorReportsHealthCheck>();
services.AddScoped<IHealthCheckService, HealthCheckService>(); services.AddScoped<IHealthCheckService, HealthCheckService>();
services.AddScoped<IChannelRepository, ChannelRepository>(); services.AddScoped<IChannelRepository, ChannelRepository>();

Loading…
Cancel
Save