Skip to content

Commit

Permalink
CU-8688kakx4 reverting console changes for Sentry.Profiling looks lik…
Browse files Browse the repository at this point in the history
…e there maybe a queue issue
  • Loading branch information
ucswift committed May 24, 2024
1 parent 39c7e74 commit b2f467b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 50 deletions.
15 changes: 2 additions & 13 deletions Core/Resgrid.Framework/Logging.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion Core/Resgrid.Framework/Resgrid.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="Sentry.Profiling" Version="4.6.2" />
<PackageReference Include="Sentry.Serilog" Version="4.6.2" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CqrsEvent>(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<CqrsEvent>(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) =>
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="Sentry.Profiling" Version="4.6.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Resgrid.Config\Resgrid.Config.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="Sentry.Profiling" Version="4.6.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
Expand Down
1 change: 1 addition & 0 deletions Web/Resgrid.WebCore/Resgrid.WebCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="Sentry.Profiling" Version="4.6.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
Expand Down
2 changes: 1 addition & 1 deletion Workers/Resgrid.Workers.Console/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit b2f467b

Please sign in to comment.