mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds OpenTelemetry pipelines and health probes to the presentation layer
This commit is contained in:
1 parent
a2c99b1b79
commit
6af3d4f5e5
22 files changed
+800
-20
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||
using Lumina.Presentation.Web.Common.HealthChecks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
|
||||
/// <summary>
|
||||
/// API reachability health check that always reports a healthy state.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal sealed class HealthyApiReachabilityHealthCheck : ApiReachabilityHealthCheck
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HealthyApiReachabilityHealthCheck"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">Injected factory for creating HTTP clients.</param>
|
||||
/// <param name="serverConfigurationOptions">Injected server configuration application settings.</param>
|
||||
public HealthyApiReachabilityHealthCheck(IHttpClientFactory httpClientFactory, IOptionsSnapshot<ServerConfigurationDto> serverConfigurationOptions)
|
||||
: base(httpClientFactory, serverConfigurationOptions)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports a healthy state without probing the API.
|
||||
/// </summary>
|
||||
public override Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(HealthCheckResult.Healthy());
|
||||
}
|
||||
}
|
||||
+7
@@ -1,11 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.HealthChecks;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -58,6 +60,11 @@ public class LuminaWebFactory : WebApplicationFactory<Program>, IDisposable
|
||||
foreach (ServiceDescriptor descriptor in apiClientDescriptors)
|
||||
services.Remove(descriptor);
|
||||
services.AddSingleton<IApiHttpClient>(ApiClientStub);
|
||||
|
||||
// the API reachability health check resolves ApiReachabilityHealthCheck from DI when it runs; replace its
|
||||
// registration with a healthy subclass, since no real API exists during these tests
|
||||
services.RemoveAll<ApiReachabilityHealthCheck>();
|
||||
services.AddScoped<ApiReachabilityHealthCheck, HealthyApiReachabilityHealthCheck>();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user