From b2f467b2edfb618222fcc1becba5d2691e1485b7 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Fri, 24 May 2024 16:48:41 -0700 Subject: [PATCH] CU-8688kakx4 reverting console changes for Sentry.Profiling looks like there maybe a queue issue --- Core/Resgrid.Framework/Logging.cs | 15 +--- .../Resgrid.Framework.csproj | 1 - .../RabbitInboundQueueProvider.cs | 73 ++++++++++--------- .../Resgrid.Web.Eventing.csproj | 1 + .../Resgrid.Web.ServicesCore.csproj | 1 + Web/Resgrid.WebCore/Resgrid.WebCore.csproj | 1 + Workers/Resgrid.Workers.Console/Dockerfile | 2 +- 7 files changed, 44 insertions(+), 50 deletions(-) diff --git a/Core/Resgrid.Framework/Logging.cs b/Core/Resgrid.Framework/Logging.cs index f1ae54ae..1c0520b2 100644 --- a/Core/Resgrid.Framework/Logging.cs +++ b/Core/Resgrid.Framework/Logging.cs @@ -1,18 +1,14 @@ -using Microsoft.Extensions.Options; -using Resgrid.Config; +using Resgrid.Config; using Sentry; -using Sentry.Profiling; using Serilog; using Serilog.Core; using Serilog.Events; using Serilog.Sinks.Elasticsearch; using System; -using System.Diagnostics; using System.Net; using System.Net.Mail; using System.Reflection; using System.Runtime.CompilerServices; -using static NodaTime.TimeZones.ZoneEqualityComparer; namespace Resgrid.Framework { @@ -46,14 +42,7 @@ public static void Initialize(string key) o.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate; o.Environment = ExternalErrorConfig.Environment; o.Release = Assembly.GetEntryAssembly().GetName().Version.ToString(); - o.ProfilesSampleRate = ExternalErrorConfig.SentryProfilingSampleRate; - - // Requires NuGet package: Sentry.Profiling - // Note: By default, the profiler is initialized asynchronously. This can be tuned by passing a desired initialization timeout to the constructor. - o.AddIntegration(new ProfilingIntegration( - // During startup, wait up to 500ms to profile the app startup code. This could make launching the app a bit slower so comment it out if your prefer profiling to start asynchronously - //TimeSpan.FromMilliseconds(500) - )); + o.ProfilesSampleRate = 0.0; }).CreateLogger(); } else if (SystemBehaviorConfig.ErrorLoggerType == ErrorLoggerTypes.Elk) diff --git a/Core/Resgrid.Framework/Resgrid.Framework.csproj b/Core/Resgrid.Framework/Resgrid.Framework.csproj index a369097f..58742954 100644 --- a/Core/Resgrid.Framework/Resgrid.Framework.csproj +++ b/Core/Resgrid.Framework/Resgrid.Framework.csproj @@ -17,7 +17,6 @@ - diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs index 7c9beb76..79347012 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs +++ b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs @@ -287,45 +287,53 @@ private async Task StartMonitoring() } }; - var paymentEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); - paymentEventQueueReceivedConsumer.Received += async (model, ea) => + if (PaymentEventQueueReceived != null) { - if (ea != null && ea.Body.Length > 0) + var paymentEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); + paymentEventQueueReceivedConsumer.Received += async (model, ea) => { - CqrsEvent cqrs = null; - try - { - var body = ea.Body; - var message = Encoding.UTF8.GetString(body.ToArray()); - cqrs = ObjectSerialization.Deserialize(message); - } - catch (Exception ex) + if (ea != null && ea.Body.Length > 0) { - _channel.BasicNack(ea.DeliveryTag, false, false); - Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); - } + CqrsEvent cqrs = null; + try + { + var body = ea.Body; + var message = Encoding.UTF8.GetString(body.ToArray()); + cqrs = ObjectSerialization.Deserialize(message); + } + catch (Exception ex) + { + _channel.BasicNack(ea.DeliveryTag, false, false); + Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); + } - try - { - if (cqrs != null) + try { - if (PaymentEventQueueReceived != null) + if (cqrs != null) { - await PaymentEventQueueReceived.Invoke(cqrs); - _channel.BasicAck(ea.DeliveryTag, false); + if (PaymentEventQueueReceived != null) + { + await PaymentEventQueueReceived.Invoke(cqrs); + _channel.BasicAck(ea.DeliveryTag, false); + } } } + catch (Exception ex) + { + Logging.LogException(ex); + if (RetryQueueItem(ea, ex)) + _channel.BasicAck(ea.DeliveryTag, false); + else + _channel.BasicNack(ea.DeliveryTag, false, true); + } } - catch (Exception ex) - { - Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); - else - _channel.BasicNack(ea.DeliveryTag, false, true); - } - } - }; + }; + + String paymentEventQueueReceivedConsumerTag = _channel.BasicConsume( + queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.PaymentQueueName), + autoAck: false, + consumer: paymentEventQueueReceivedConsumer); + } var auditEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); auditEventQueueReceivedConsumer.Received += async (model, ea) => @@ -473,11 +481,6 @@ private async Task StartMonitoring() autoAck: false, consumer: cqrsEventQueueReceivedConsumer); - String paymentEventQueueReceivedConsumerTag = _channel.BasicConsume( - queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.PaymentQueueName), - autoAck: false, - consumer: paymentEventQueueReceivedConsumer); - String auditEventQueueReceivedConsumerTag = _channel.BasicConsume( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.AuditQueueName), autoAck: false, diff --git a/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj b/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj index 0d81563a..16d1d8c7 100644 --- a/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj +++ b/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj @@ -45,6 +45,7 @@ + diff --git a/Web/Resgrid.Web.ServicesCore/Resgrid.Web.ServicesCore.csproj b/Web/Resgrid.Web.ServicesCore/Resgrid.Web.ServicesCore.csproj index 28409952..bd239032 100644 --- a/Web/Resgrid.Web.ServicesCore/Resgrid.Web.ServicesCore.csproj +++ b/Web/Resgrid.Web.ServicesCore/Resgrid.Web.ServicesCore.csproj @@ -66,6 +66,7 @@ + diff --git a/Web/Resgrid.WebCore/Resgrid.WebCore.csproj b/Web/Resgrid.WebCore/Resgrid.WebCore.csproj index 41654deb..9c9de9f1 100644 --- a/Web/Resgrid.WebCore/Resgrid.WebCore.csproj +++ b/Web/Resgrid.WebCore/Resgrid.WebCore.csproj @@ -60,6 +60,7 @@ + diff --git a/Workers/Resgrid.Workers.Console/Dockerfile b/Workers/Resgrid.Workers.Console/Dockerfile index 34ee080e..46753d3b 100644 --- a/Workers/Resgrid.Workers.Console/Dockerfile +++ b/Workers/Resgrid.Workers.Console/Dockerfile @@ -1,7 +1,7 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. ARG BUILD_VERSION=3.5.0 -FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-jammy-amd64 AS base +FROM mcr.microsoft.com/dotnet/runtime:8.0.3-jammy-amd64 AS base ARG BUILD_VERSION WORKDIR /app