-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathStartup.HealthChecks.cs
67 lines (55 loc) · 2.05 KB
/
Startup.HealthChecks.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Collections.Generic;
using Bet.AspNetCore.Sample;
using Bet.Extensions.ML.Sentiment.Models;
using Bet.Extensions.ML.Spam.Models;
using Microsoft.Extensions.Configuration;
namespace Microsoft.Extensions.DependencyInjection
{
public static class HealthChecksExtensions
{
public static IServiceCollection AddAppHealthChecks(
this IServiceCollection services,
IConfiguration configuration)
{
var isLocal = configuration.GetValue<bool>("LocalMLModels");
var builder = services.AddHealthChecks();
if (!isLocal)
{
// blob hc check
builder.AddAzureBlobStorageCheck("betstorage_check", "models", options =>
{
options.Name = "betstorage";
})
// queue hc check
.AddAzureQueuetorageCheck("queue_check", "betqueue");
}
// memory hc check
builder.AddMemoryHealthCheck()
// spam hc check
.AddMachineLearningModelCheck<SpamInput, SpamPrediction>(
$"{MLModels.SpamModel}_check",
options =>
{
options.ModelName = MLModels.SpamModel;
options.SampleData = new SpamInput
{
Message = "That's a great idea. It should work."
};
})
// sentiment hc check
.AddMachineLearningModelCheck<SentimentIssue, SentimentPrediction>(
$"{MLModels.SentimentModel}_check",
options =>
{
options.ModelName = MLModels.SentimentModel;
options.SampleData = new SentimentIssue
{
Text = "This is a very rude movie"
};
})
.AddSigtermCheck("sigterm_check")
.AddLoggerPublisher(new List<string> { "sigterm_check" });
return services;
}
}
}