Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.05k stars 793 forks source link

Unexpected timeout exception #2233

Open MaxiPigna opened 3 months ago

MaxiPigna commented 3 months ago

Given this source code

builder.Services.AddHealthChecks()
    .AddAzureCosmosDB(optionsFactory: static (sp) =>
    {
        CosmosDbOptions cosmosConfig = sp.GetRequiredService<IOptions<CosmosDbOptions>>().Value;
        return new AzureCosmosDbHealthCheckOptions
        {
            DatabaseId = cosmosConfig.DatabaseName,
            ContainerIds = [Constants.ConversationContainerName]
        };
    }, tags: ["Database"], timeout: TimeSpan.FromSeconds(2))

It works most of the time, but sometimes I find exception like this in the log, why?

image

I think it's weird I get a timeout exception, while Cosmos replied 200 OK in the expected time.

Environment: