Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health check dimension in the default constructor for tag definon #709

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Microsoft.Omex.Extensions.Activities
public class CustomTagObjectsDimensions : ICustomTagObjectsDimensions
{
/// <summary>
/// Default constructor which has <seealso cref="ActivityTagKeys.Result"/>, <seealso cref="ActivityTagKeys.SubType"/>, <seealso cref="ActivityTagKeys.Metadata"/>
/// Default constructor which has <seealso cref="ActivityTagKeys.Result"/>, <seealso cref="ActivityTagKeys.SubType"/>, <seealso cref="ActivityTagKeys.Metadata"/>, <seealso cref="ActivityTagKeys.HealthCheckResult"/>
/// </summary>
public CustomTagObjectsDimensions() => CustomDimensions = new HashSet<string>() { ActivityTagKeys.Result, ActivityTagKeys.SubType, ActivityTagKeys.Metadata };
public CustomTagObjectsDimensions() => CustomDimensions = new HashSet<string>() { ActivityTagKeys.Result, ActivityTagKeys.SubType, ActivityTagKeys.Metadata, ActivityTagKeys.HealthCheckResult };
andrei5090 marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Override the default constructor to specify custom dimension set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
{
HealthCheckResult result = await m_wrappedHealthCheck.CheckHealthAsync(context, cancellationToken);

try
{
activity?.SetTag(ActivityTagKeys.HealthCheckResult, result.Status.ToString());
}
catch (Exception ex)
{
m_logger.LogError(Tag.Create(), ex, "'{registrationName}' 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,
Expand All @@ -75,6 +66,8 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
? result.Status
: context.Registration.FailureStatus;

activity?.SetTag(ActivityTagKeys.HealthCheckResult, healthCheckStatus.ToString());

return new HealthCheckResult(
healthCheckStatus,
result.Description,
Expand Down
Loading