Skip to content

Commit

Permalink
Add optional tag for health check
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Ionescu committed Dec 10, 2024
1 parent 8bc2ee6 commit 2c4d856
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,19 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
try
{
HealthCheckResult result = await m_wrappedHealthCheck.CheckHealthAsync(context, cancellationToken);

try
{
activity?.SetTag("HealthCheckResult", result.Status.ToString());
}
catch (Exception ex) {
m_logger.LogError(Tag.Create(), ex, "'{0}' health check tag addition failed", context.Registration.Name);
}

activity?.MarkAsSuccess();

// The health status for the health check result: if the status is healthy, it will be returned as it is,
// if not then then registration failure status will be sent in its place.
// if not then registration failure status will be sent in its place.
HealthStatus healthCheckStatus = result.Status == HealthStatus.Healthy
? result.Status
: context.Registration.FailureStatus;
Expand Down

0 comments on commit 2c4d856

Please sign in to comment.