From 07b1ac4a61353b208e8164a96e9a97aceb21665b Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Wed, 21 Sep 2022 13:20:45 -0700 Subject: [PATCH] Log time for a payload to complete end-to-end within the service. Signed-off-by: Victor Chang --- src/Api/Storage/Payload.cs | 2 ++ src/Database/PayloadConfiguration.cs | 1 + src/InformaticsGateway/Logging/Log.700.PayloadService.cs | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Api/Storage/Payload.cs b/src/Api/Storage/Payload.cs index d0fcb4e3e..af584bb20 100644 --- a/src/Api/Storage/Payload.cs +++ b/src/Api/Storage/Payload.cs @@ -66,6 +66,8 @@ public enum PayloadState public bool HasTimedOut { get => ElapsedTime().TotalSeconds >= Timeout; } + public TimeSpan Elapsed { get { return DateTime.UtcNow.Subtract(DateTimeCreated); } } + public string CallingAeTitle { get => Files.OfType().Select(p => p.CallingAeTitle).FirstOrDefault(); } public string CalledAeTitle { get => Files.OfType().Select(p => p.CalledAeTitle).FirstOrDefault(); } diff --git a/src/Database/PayloadConfiguration.cs b/src/Database/PayloadConfiguration.cs index 171b10ac1..b40c9e7c1 100644 --- a/src/Database/PayloadConfiguration.cs +++ b/src/Database/PayloadConfiguration.cs @@ -57,6 +57,7 @@ public void Configure(EntityTypeBuilder builder) builder.Ignore(j => j.CalledAeTitle); builder.Ignore(j => j.CallingAeTitle); builder.Ignore(j => j.HasTimedOut); + builder.Ignore(j => j.Elapsed); builder.Ignore(j => j.Count); } } diff --git a/src/InformaticsGateway/Logging/Log.700.PayloadService.cs b/src/InformaticsGateway/Logging/Log.700.PayloadService.cs index 588669efe..5cb9aaa3f 100644 --- a/src/InformaticsGateway/Logging/Log.700.PayloadService.cs +++ b/src/InformaticsGateway/Logging/Log.700.PayloadService.cs @@ -53,8 +53,8 @@ public static partial class Log [LoggerMessage(EventId = 711, Level = LogLevel.Information, Message = "Publishing workflow request message ID={messageId}...")] public static partial void PublishingWorkflowRequest(this ILogger logger, string messageId); - [LoggerMessage(EventId = 712, Level = LogLevel.Information, Message = "Workflow request published to {queue}, message ID={messageId}.")] - public static partial void WorkflowRequestPublished(this ILogger logger, string queue, string messageId); + [LoggerMessage(EventId = 712, Level = LogLevel.Information, Message = "Workflow request published to {queue}, message ID={messageId}. Payload took {payloadElapsedTime} to complete.")] + public static partial void WorkflowRequestPublished(this ILogger logger, string queue, string messageId, TimeSpan payloadElapsedTime); [LoggerMessage(EventId = 713, Level = LogLevel.Information, Message = "Restoring payloads from database.")] public static partial void StartupRestoreFromDatabase(this ILogger logger);