From 8903e2fe4a6e392de2d04baa6f28d63d41184368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Thu, 13 Jun 2024 16:40:10 +0200 Subject: [PATCH 1/2] fix: #87 add activity to AzureServiceBusHealthCheck --- .../Health/AzureServiceBusHealthCheck.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs b/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs index 4f8e378..1728a35 100644 --- a/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs +++ b/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs @@ -30,6 +30,7 @@ public AzureServiceBusHealthCheck(string connectionString, string queueName) public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { + using var activity = Observability.DefaultActivities.StartActivity(); try { var client = ClientConnections.GetOrAdd(_queueName, _ => new ServiceBusClient(_connectionString)); From 377298fcd6927c4be0c9d1c8b203834e66f66d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Thu, 13 Jun 2024 16:46:57 +0200 Subject: [PATCH 2/2] fix: added recordException to activity of AzureServiceBusHealthCheck --- .../Health/AzureServiceBusHealthCheck.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs b/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs index 1728a35..2c05404 100644 --- a/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs +++ b/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Health/AzureServiceBusHealthCheck.cs @@ -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 { @@ -40,6 +41,8 @@ public async Task CheckHealthAsync(HealthCheckContext context } catch (TaskCanceledException ex) { + activity?.RecordException(ex); + // propagate the exception if the cancellation token has been canceled if (cancellationToken.IsCancellationRequested) { @@ -50,6 +53,7 @@ public async Task CheckHealthAsync(HealthCheckContext context } catch (Exception ex) { + activity?.RecordException(ex); return new HealthCheckResult(context.Registration.FailureStatus, exception: ex); } }