Skip to content

Commit

Permalink
Log duration of export request
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Sep 8, 2023
1 parent a319c70 commit ae3e0d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/InformaticsGateway/Logging/Log.500.ExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public static partial class Log
[LoggerMessage(EventId = 504, Level = LogLevel.Debug, Message = "File {file} ready for export.")]
public static partial void FileReadyForExport(this ILogger logger, string file);

[LoggerMessage(EventId = 505, Level = LogLevel.Information, Message = "Export task completed with {failedCount} failures out of {fileCount}.")]
public static partial void ExportCompleted(this ILogger logger, int failedCount, int fileCount);
[LoggerMessage(EventId = 505, Level = LogLevel.Information, Message = "Export task completed with {failedCount} failures out of {fileCount}. Time to export: {durationMilliseconds}ms.")]
public static partial void ExportCompleted(this ILogger logger, int failedCount, int fileCount, int durationMilliseconds);

[LoggerMessage(EventId = 506, Level = LogLevel.Error, Message = "Error downloading payload. Waiting {timeSpan} before next retry. Retry attempt {retryCount}.")]
public static partial void ErrorDownloadingPayloadWithRetry(this ILogger logger, Exception ex, TimeSpan timeSpan, int retryCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ public ExportRequestEventDetails(ExportRequestEvent exportRequest)

PluginAssemblies.AddRange(exportRequest.PluginAssemblies);
ErrorMessages.AddRange(exportRequest.ErrorMessages);

StartTime = DateTimeOffset.UtcNow;
}

/// <summary>
/// Gets the time the export request received.
/// </summary>
public DateTimeOffset StartTime { get; }


/// <summary>
/// Gets time between now and <see cref="StartTime"/>.
/// </summary>
public TimeSpan Duration
{
get
{
return DateTimeOffset.UtcNow.Subtract(StartTime);
}
}

/// <summary>
Expand All @@ -53,7 +72,12 @@ public ExportRequestEventDetails(ExportRequestEvent exportRequest)
/// Gets whether the export task is completed or not based on file count.
/// </summary>
public bool IsCompleted
{ get { return (SucceededFiles + FailedFiles) == Files.Count(); } }
{
get
{
return (SucceededFiles + FailedFiles) == Files.Count();
}
}

public Dictionary<string, FileExportStatus> FileStatuses { get; private set; } = new Dictionary<string, FileExportStatus>();

Expand Down
5 changes: 2 additions & 3 deletions src/InformaticsGateway/Services/Export/ExportServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ private async Task<ExportRequestDataMessage> ExecuteOutputDataEngineCallback(Exp

private void ReportingActionBlock(ExportRequestDataMessage exportRequestData)
{
using var loggerScope = _logger.BeginScope(new Api.LoggingDataDictionary<string, object> { { "ExportTaskId", exportRequestData.ExportTaskId }, { "CorrelationId", exportRequestData.CorrelationId } });

var exportRequest = _exportRequests[exportRequestData.ExportTaskId];
lock (SyncRoot)
{
Expand All @@ -309,7 +307,8 @@ private void ReportingActionBlock(ExportRequestDataMessage exportRequestData)
}
}

_logger.ExportCompleted(exportRequest.FailedFiles, exportRequest.Files.Count());
using var loggerScope = _logger.BeginScope(new Api.LoggingDataDictionary<string, object> { { "ExportTaskId", exportRequestData.ExportTaskId }, { "CorrelationId", exportRequestData.CorrelationId } });
_logger.ExportCompleted(exportRequest.FailedFiles, exportRequest.Files.Count(), exportRequest.Duration.TotalMilliseconds);

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebStow, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebStow, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebExport, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebExport, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (RemoteAppExecutionPlugIn, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (RemoteAppExecutionPlugIn, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebExport, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebExport, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebStow, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomWebStow, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (AcrApi, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (AcrApi, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (AcrApi, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (AcrApi, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (Fhir, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (Fhir, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScu, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScu, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScu, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScu, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (Fhir, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (Fhir, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScp, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScp, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (HealthLevel7, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (HealthLevel7, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScp, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (DicomDimseScp, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (HealthLevel7, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (HealthLevel7, ef)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (RemoteAppExecutionPlugIn, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / integration-test (RemoteAppExecutionPlugIn, mongodb)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / analyze

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / analyze

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / unit-test

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / unit-test

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Analyze

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Analyze

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / docs

Argument 4: cannot convert from 'double' to 'int'

Check failure on line 311 in src/InformaticsGateway/Services/Export/ExportServiceBase.cs

View workflow job for this annotation

GitHub Actions / docs

Argument 4: cannot convert from 'double' to 'int'

var exportCompleteEvent = new ExportCompleteEvent(exportRequest, exportRequest.Status, exportRequest.FileStatuses);

Expand Down

0 comments on commit ae3e0d0

Please sign in to comment.