< Summary

Information
Class: Chronicis.Api.Services.AzureOpenAIHealthCheckService
Assembly: Chronicis.Api
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/AzureOpenAIHealthCheckService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 43
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
PerformHealthCheckAsync()0%4260%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/AzureOpenAIHealthCheckService.cs

#LineLine coverage
 1using Chronicis.Shared.DTOs;
 2
 3namespace Chronicis.Api.Services;
 4
 5public class AzureOpenAIHealthCheckService : HealthCheckServiceBase
 6{
 7    private readonly IConfiguration _configuration;
 8    private readonly HttpClient _httpClient;
 9
 10    public AzureOpenAIHealthCheckService(
 11        IConfiguration configuration,
 12        HttpClient httpClient,
 13        ILogger<AzureOpenAIHealthCheckService> logger)
 014        : base(logger)
 15    {
 016        _configuration = configuration;
 017        _httpClient = httpClient;
 018    }
 19
 20    protected override Task<(string Status, string? Message)> PerformHealthCheckAsync()
 21    {
 022        var endpoint = _configuration["AzureOpenAI:Endpoint"];
 023        var apiKey = _configuration["AzureOpenAI:ApiKey"];
 024        var deploymentName = _configuration["AzureOpenAI:DeploymentName"];
 25
 026        if (string.IsNullOrEmpty(endpoint) || string.IsNullOrEmpty(apiKey) || string.IsNullOrEmpty(deploymentName))
 27        {
 028            return Task.FromResult<(string Status, string? Message)>((HealthStatus.Unhealthy, "Azure OpenAI configuratio
 29        }
 30
 31        // For a lightweight check, we'll just verify the configuration is complete
 32        // A full check would require making an actual API call, but that might be expensive
 33        try
 34        {
 035            var uri = new Uri(endpoint);
 036            return Task.FromResult<(string Status, string? Message)>((HealthStatus.Healthy, "Azure OpenAI configuration 
 37        }
 038        catch (UriFormatException)
 39        {
 040            return Task.FromResult<(string Status, string? Message)>((HealthStatus.Unhealthy, "Azure OpenAI endpoint URL
 41        }
 042    }
 43}