Skip to content

Commit

Permalink
Merge branch 'feat/remote-processing' of https://github.com/wemogy/li…
Browse files Browse the repository at this point in the history
…bs-cqrs into feat/remote-processing
  • Loading branch information
SebastianKuesters committed Jun 25, 2024
2 parents d4dbce6 + f059ae7 commit 989059c
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using OpenTelemetry.Trace;

namespace Wemogy.CQRS.Extensions.AzureServiceBus.Health
{
Expand All @@ -30,6 +31,7 @@ public AzureServiceBusHealthCheck(string connectionString, string queueName)

public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
using var activity = Observability.DefaultActivities.StartActivity();
try
{
var client = ClientConnections.GetOrAdd(_queueName, _ => new ServiceBusClient(_connectionString));
Expand All @@ -39,6 +41,8 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
}
catch (TaskCanceledException ex)
{
activity?.RecordException(ex);

// propagate the exception if the cancellation token has been canceled
if (cancellationToken.IsCancellationRequested)
{
Expand All @@ -49,6 +53,7 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
}
catch (Exception ex)
{
activity?.RecordException(ex);
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
Expand Down

0 comments on commit 989059c

Please sign in to comment.