Skip to content

Commit

Permalink
Abzu-97705-Moved Apm transaction code from program to fulfilment serv…
Browse files Browse the repository at this point in the history
…ice job class. (#235)
  • Loading branch information
JiviteshT authored Oct 16, 2023
1 parent b9823ff commit 7619663
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 32 deletions.
9 changes: 9 additions & 0 deletions NVDSuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,13 @@
<cve>CVE-2021-37941</cve>
<cve>CVE-2019-7617</cve>
</suppress>
<suppress>
<notes>
<![CDATA[
file name: Azure.Identity:1.8.2
]]>
</notes>
<packageUrl regex="true">^pkg:nuget/Azure\.Identity@.*$</packageUrl>
<cve>CVE-2023-36414</cve>
</suppress>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
using Elastic.Apm;
using Elastic.Apm.Api;
using UKHO.ExchangeSetService.Common.Configuration;
using UKHO.ExchangeSetService.Common.Extensions;
using UKHO.ExchangeSetService.Common.Helpers;
Expand Down Expand Up @@ -68,28 +70,37 @@ public async Task ProcessQueueMessage([QueueTrigger("%ESSFulfilmentStorageConfig
logger.LogInformation(EventIds.AIOToggleIsOff.ToEventId(), "ESS Webjob : AIO toggle is OFF for BatchId:{BatchId} | _X-Correlation-ID : {CorrelationId}", fulfilmentServiceQueueMessage.BatchId, fulfilmentServiceQueueMessage.CorrelationId);
}

if (CommonHelper.IsPeriodicOutputService)
{
await logger.LogStartEndAndElapsedTimeAsync(EventIds.CreateLargeExchangeSetRequestStart,
EventIds.CreateLargeExchangeSetRequestCompleted,
"Create Large Exchange Set web job request for BatchId:{BatchId} and _X-Correlation-ID:{CorrelationId}",
async () =>
{
return await fulFilmentDataService.CreateLargeExchangeSet(fulfilmentServiceQueueMessage, currentUtcDate, periodicOutputServiceConfiguration.Value.LargeExchangeSetFolderName);
},
fulfilmentServiceQueueMessage.BatchId, fulfilmentServiceQueueMessage.CorrelationId);
}
else
string transactionName =
$"{System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME")}-fulfilment-transaction";

await Agent.Tracer.CaptureTransaction(transactionName, ApiConstants.TypeRequest, async () =>
{
await logger.LogStartEndAndElapsedTimeAsync(EventIds.CreateExchangeSetRequestStart,
EventIds.CreateExchangeSetRequestCompleted,
"Create Exchange Set web job request for BatchId:{BatchId} and _X-Correlation-ID:{CorrelationId}",
async () =>
{
return await fulFilmentDataService.CreateExchangeSet(fulfilmentServiceQueueMessage, currentUtcDate);
},
fulfilmentServiceQueueMessage.BatchId, fulfilmentServiceQueueMessage.CorrelationId);
}
if (CommonHelper.IsPeriodicOutputService)
{
await logger.LogStartEndAndElapsedTimeAsync(EventIds.CreateLargeExchangeSetRequestStart,
EventIds.CreateLargeExchangeSetRequestCompleted,
"Create Large Exchange Set web job request for BatchId:{BatchId} and _X-Correlation-ID:{CorrelationId}",
async () =>
{
return await fulFilmentDataService.CreateLargeExchangeSet(fulfilmentServiceQueueMessage,
currentUtcDate,
periodicOutputServiceConfiguration.Value.LargeExchangeSetFolderName);
},
fulfilmentServiceQueueMessage.BatchId, fulfilmentServiceQueueMessage.CorrelationId);
}
else
{
await logger.LogStartEndAndElapsedTimeAsync(EventIds.CreateExchangeSetRequestStart,
EventIds.CreateExchangeSetRequestCompleted,
"Create Exchange Set web job request for BatchId:{BatchId} and _X-Correlation-ID:{CorrelationId}",
async () =>
{
return await fulFilmentDataService.CreateExchangeSet(fulfilmentServiceQueueMessage,
currentUtcDate);
},
fulfilmentServiceQueueMessage.BatchId, fulfilmentServiceQueueMessage.CorrelationId);
}
});
}
catch (Exception ex)
{
Expand All @@ -105,6 +116,12 @@ await logger.LogStartEndAndElapsedTimeAsync(EventIds.CreateExchangeSetRequestSta

if (ex.GetType() != typeof(FulfilmentException))
logger.LogError(exceptionEventId, ex, "Unhandled exception while processing Exchange Set web job for BatchId:{BatchId} and _X-Correlation-ID:{CorrelationId} and Exception:{Message}", fulfilmentServiceQueueMessage.BatchId, fulfilmentServiceQueueMessage.CorrelationId, ex.Message);

Agent.Tracer.CurrentTransaction?.CaptureException(ex);
}
finally
{
Agent.Tracer.CurrentTransaction?.End();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
using Microsoft.ApplicationInsights.Extensibility;
using UKHO.ExchangeSetService.FulfilmentService.Filters;
using UKHO.ExchangeSetService.FulfilmentService.Validation;
using System.Collections.Generic;
using Elastic.Apm.Azure.Storage;
using Elastic.Apm.DiagnosticSource;
using Elastic.Apm;
using Elastic.Apm.Api;

namespace UKHO.ExchangeSetService.FulfilmentService
{
Expand All @@ -49,16 +47,11 @@ public static void Main(string[] args)

HostBuilder hostBuilder = BuildHostConfiguration();
IHost host = hostBuilder.Build();
string transactionName = $"{System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME")}-fulfilment-transaction";

Agent.Tracer.CaptureTransaction(transactionName, ApiConstants.TypeRequest, () =>

using (host)
{
using (host)
{
host.Run();
}
});

host.Run();
}
}
private static HostBuilder BuildHostConfiguration()
{
Expand Down

0 comments on commit 7619663

Please sign in to comment.