Skip to content

Commit

Permalink
Log time for a payload to complete end-to-end within the service.
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <vicchang@nvidia.com>
  • Loading branch information
mocsharp committed Sep 21, 2022
1 parent fc88f67 commit f28d1a5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Api/Storage/Payload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DicomFileStorageMetadata>().Select(p => p.CallingAeTitle).FirstOrDefault(); }

public string CalledAeTitle { get => Files.OfType<DicomFileStorageMetadata>().Select(p => p.CalledAeTitle).FirstOrDefault(); }
Expand Down
1 change: 1 addition & 0 deletions src/Database/PayloadConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void Configure(EntityTypeBuilder<Payload> 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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/InformaticsGateway/Logging/Log.700.PayloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ await _messageBrokerPublisherService.Publish(
_options.Value.Messaging.Topics.WorkflowRequest,
message.ToMessage()).ConfigureAwait(false);

_logger.WorkflowRequestPublished(_options.Value.Messaging.Topics.WorkflowRequest, message.MessageId);
_logger.WorkflowRequestPublished(_options.Value.Messaging.Topics.WorkflowRequest, message.MessageId, payload.Elapsed);
}

private async Task<PayloadAction> UpdatePayloadState(Payload payload)
Expand Down

0 comments on commit f28d1a5

Please sign in to comment.