Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit b439352

Browse files
authored
Merge pull request #974 from mvelosop/fix/health-check-report-collector-exception
Fix/health check report collector exception
2 parents 86b4b76 + d5adb5f commit b439352

File tree

5 files changed

+135
-90
lines changed

5 files changed

+135
-90
lines changed

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ services:
324324

325325
webstatus:
326326
environment:
327-
- ASPNETCORE_ENVIRONMENT=Development
327+
- ASPNETCORE_ENVIRONMENT=Production
328328
- ASPNETCORE_URLS=http://0.0.0.0:80
329329
- HealthChecks-UI__HealthChecks__1__Name=WebMVC HTTP Check
330330
- HealthChecks-UI__HealthChecks__1__Uri=http://webmvc/hc

src/Web/WebStatus/Program.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.Extensions.Configuration;
4-
using Microsoft.Extensions.Logging;
54
using Serilog;
65
using System;
6+
using System.Collections.Generic;
77
using System.IO;
8+
using System.Linq;
9+
using System.Reflection;
810

911
namespace WebStatus
1012
{
@@ -24,6 +26,8 @@ public static int Main(string[] args)
2426
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
2527
var host = BuildWebHost(configuration, args);
2628

29+
LogPackagesVersionInfo();
30+
2731
Log.Information("Starting web host ({ApplicationContext})...", AppName);
2832
host.Run();
2933

@@ -83,5 +87,39 @@ private static IConfiguration GetConfiguration()
8387

8488
return builder.Build();
8589
}
90+
91+
private static string GetVersion(Assembly assembly)
92+
{
93+
try
94+
{
95+
return $"{assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version} ({assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split()[0]})";
96+
}
97+
catch
98+
{
99+
return string.Empty;
100+
}
101+
}
102+
103+
private static void LogPackagesVersionInfo()
104+
{
105+
var assemblies = new List<Assembly>();
106+
107+
foreach (var dependencyName in typeof(Program).Assembly.GetReferencedAssemblies())
108+
{
109+
try
110+
{
111+
// Try to load the referenced assembly...
112+
assemblies.Add(Assembly.Load(dependencyName));
113+
}
114+
catch
115+
{
116+
// Failed to load assembly. Skip it.
117+
}
118+
}
119+
120+
var versionList = assemblies.Select(a => $"-{a.GetName().Name} - {GetVersion(a)}").OrderBy(value => value);
121+
122+
Log.Logger.ForContext("PackageVersions", string.Join("\n", versionList)).Information("Package versions ({ApplicationContext})", AppName);
123+
}
86124
}
87125
}

src/Web/WebStatus/WebStatus.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<None Remove="Views\**" />
1212
</ItemGroup>
1313
<ItemGroup>
14-
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.8" />
15-
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
16-
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
14+
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.22" />
15+
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.3" />
16+
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.2" />
1717
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
1818
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
1919
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.2" />
@@ -24,10 +24,18 @@
2424
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
2525
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
2626
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
27-
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
27+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
2828
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
2929
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
3030
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
3131
</ItemGroup>
32+
<ItemGroup>
33+
<Content Update="appsettings.Development.json">
34+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
35+
</Content>
36+
<Content Update="appsettings.json">
37+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
38+
</Content>
39+
</ItemGroup>
3240

3341
</Project>
Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,87 @@
11
{
2-
"Logging": {
3-
"IncludeScopes": false,
4-
"LogLevel": {
5-
"Default": "Debug",
6-
"System": "Information",
7-
"Microsoft": "Information"
2+
"HealthChecks-UI": {
3+
"HealthChecks": [
4+
{
5+
"Name": "Ordering HTTP Check",
6+
"Uri": "http://localhost:5102/hc"
7+
},
8+
{
9+
"Name": "Ordering HTTP Background Check",
10+
"Uri": "http://localhost:5111/hc"
11+
},
12+
{
13+
"Name": "Basket HTTP Check",
14+
"Uri": "http://localhost:5103/hc"
15+
},
16+
{
17+
"Name": "Catalog HTTP Check",
18+
"Uri": "http://localhost:5101/hc"
19+
},
20+
{
21+
"Name": "Identity HTTP Check",
22+
"Uri": "http://localhost:5105/hc"
23+
},
24+
{
25+
"Name": "Marketing HTTP Check",
26+
"Uri": "http://localhost:5110/hc"
27+
},
28+
{
29+
"Name": "Locations HTTP Check",
30+
"Uri": "http://localhost:5109/hc"
31+
},
32+
{
33+
"Name": "Payments HTTP Check",
34+
"Uri": "http://localhost:5108/hc"
35+
},
36+
{
37+
"Name": "WebMVC HTTP Check",
38+
"Uri": "http://localhost:5100/hc"
39+
},
40+
{
41+
"Name": "WebSPA HTTP Check",
42+
"Uri": "http://localhost:5104/hc"
43+
},
44+
{
45+
"Name": "SignalR HTTP Check",
46+
"Uri": "http://localhost:5112/hc"
47+
},
48+
{
49+
"Name": "Mobile Shopping API GW HTTP Check",
50+
"Uri": "http://localhost:5200/hc"
51+
},
52+
{
53+
"Name": "Mobile Marketing API GW HTTP Check",
54+
"Uri": "http://localhost:5201/hc"
55+
},
56+
{
57+
"Name": "Web Shopping API GW HTTP Check",
58+
"Uri": "http://localhost:5202/hc"
59+
},
60+
{
61+
"Name": "Web Marketing API GW HTTP Check",
62+
"Uri": "http://localhost:5203/hc"
63+
},
64+
{
65+
"Name": "Mobile Shopping Aggregator HTTP Check",
66+
"Uri": "http://localhost:5120/hc"
67+
},
68+
{
69+
"Name": "Web Shopping Aggregator HTTP Check",
70+
"Uri": "http://localhost:5121/hc"
71+
}
72+
],
73+
"EvaluationTimeOnSeconds": 10,
74+
"MinimumSecondsBetweenFailureNotifications": 60
75+
},
76+
"Serilog": {
77+
"SeqServerUrl": "http://localhost:5341/",
78+
"MinimumLevel": {
79+
"Default": "Information",
80+
"Override": {
81+
"Microsoft": "Warning",
82+
"Microsoft.eShopOnContainers": "Information",
83+
"System": "Warning"
84+
}
885
}
986
}
1087
}

src/Web/WebStatus/appsettings.json

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,5 @@
11
{
22
"HealthChecks-UI": {
3-
"HealthChecks": [
4-
{
5-
"Name": "Ordering HTTP Check",
6-
"Uri": "http://localhost:5102/hc"
7-
},
8-
{
9-
"Name": "Ordering HTTP Background Check",
10-
"Uri": "http://localhost:5111/hc"
11-
},
12-
{
13-
"Name": "Basket HTTP Check",
14-
"Uri": "http://localhost:5103/hc"
15-
},
16-
{
17-
"Name": "Catalog HTTP Check",
18-
"Uri": "http://localhost:5101/hc"
19-
},
20-
{
21-
"Name": "Identity HTTP Check",
22-
"Uri": "http://localhost:5105/hc"
23-
},
24-
{
25-
"Name": "Marketing HTTP Check",
26-
"Uri": "http://localhost:5110/hc"
27-
},
28-
{
29-
"Name": "Locations HTTP Check",
30-
"Uri": "http://localhost:5109/hc"
31-
},
32-
{
33-
"Name": "Payments HTTP Check",
34-
"Uri": "http://localhost:5108/hc"
35-
},
36-
{
37-
"Name": "WebMVC HTTP Check",
38-
"Uri": "http://localhost:5100/hc"
39-
},
40-
{
41-
"Name": "WebSPA HTTP Check",
42-
"Uri": "http://localhost:5104/hc"
43-
},
44-
{
45-
"Name": "SignalR HTTP Check",
46-
"Uri": "http://localhost:5112/hc"
47-
},
48-
{
49-
"Name": "Mobile Shopping API GW HTTP Check",
50-
"Uri": "http://localhost:5200/hc"
51-
},
52-
{
53-
"Name": "Mobile Marketing API GW HTTP Check",
54-
"Uri": "http://localhost:5201/hc"
55-
},
56-
{
57-
"Name": "Web Shopping API GW HTTP Check",
58-
"Uri": "http://localhost:5202/hc"
59-
},
60-
{
61-
"Name": "Web Marketing API GW HTTP Check",
62-
"Uri": "http://localhost:5203/hc"
63-
},
64-
{
65-
"Name": "Mobile Shopping Aggregator HTTP Check",
66-
"Uri": "http://localhost:5120/hc"
67-
},
68-
{
69-
"Name": "Web Shopping Aggregator HTTP Check",
70-
"Uri": "http://localhost:5121/hc"
71-
}
72-
],
73-
"Webhooks": [
74-
{
75-
"Name": "",
76-
"Uri": "",
77-
"Payload": "",
78-
"RestoredPayload": ""
79-
}
80-
],
813
"EvaluationTimeOnSeconds": 10,
824
"MinimumSecondsBetweenFailureNotifications": 60
835
},

0 commit comments

Comments
 (0)