Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding better logging #871

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Common/Configuration/WorkflowManagerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class WorkflowManagerOptions : PagedOptions
public string DicomTagsDisallowed { get; set; } = string.Empty;

[ConfigurationKeyName("migExternalAppPlugins")]
public List<string> MigExternalAppPlugins { get; set; }
public string[] MigExternalAppPlugins { get; set; }

public WorkflowManagerOptions()
{
Expand Down
3 changes: 3 additions & 0 deletions src/WorkflowManager/Logging/Log.200000.Workflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,8 @@ public static partial class Log

[LoggerMessage(EventId = 210006, Level = LogLevel.Information, Message = "Attached PatientMetadata {metadata}.")]
public static partial void AttachedPatientMetadataToTaskExec(this ILogger logger, string metadata);

[LoggerMessage(EventId = 210007, Level = LogLevel.Information, Message = "Exporting to MIG task Id {taskid}, export destination {destination} number of files {fileCount} Mig data plugins {plugins}.")]
public static partial void LogMigExport(this ILogger logger, string taskid, string destination, int fileCount, string plugins);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
private string ExportRequestRoutingKey { get; }
private string TaskTimeoutRoutingKey { get; }

public WorkflowExecuterService(

Check warning on line 63 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Constructor has 12 parameters, which is greater than the 7 authorized. (https://rules.sonarsource.com/csharp/RSPEC-107)
ILogger<WorkflowExecuterService> logger,
IOptions<WorkflowManagerOptions> configuration,
IOptions<StorageServiceConfiguration> storageConfiguration,
Expand Down Expand Up @@ -89,7 +89,7 @@
_defaultPerTaskTypeTimeoutMinutes = configuration.Value.PerTaskTypeTimeoutMinutes;
TaskDispatchRoutingKey = configuration.Value.Messaging.Topics.TaskDispatchRequest;
TaskTimeoutRoutingKey = configuration.Value.Messaging.Topics.AideClinicalReviewCancelation;
_migExternalAppPlugins = configuration.Value.MigExternalAppPlugins;
_migExternalAppPlugins = configuration.Value.MigExternalAppPlugins.ToList();
ExportRequestRoutingKey = $"{configuration.Value.Messaging.Topics.ExportRequestPrefix}.{configuration.Value.Messaging.DicomAgents.ScuAgentName}";

_logger = logger ?? throw new ArgumentNullException(nameof(logger));
Expand All @@ -111,7 +111,7 @@
using var loggerScope = _logger.BeginScope($"correlationId={message.CorrelationId}, payloadId={payload.PayloadId}");

// for external App executions then workflowInstanceId will be supplied and we can continue the workflow from that task.
if (string.IsNullOrWhiteSpace(message.WorkflowInstanceId) is false)

Check warning on line 114 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
var instance = await _workflowInstanceRepository.GetByWorkflowInstanceIdAsync(message.WorkflowInstanceId);
if (instance is not null)
Expand Down Expand Up @@ -139,7 +139,7 @@
workflows = new List<WorkflowRevision>(result);
}

if (workflows is null || workflows.Any() is false)

Check warning on line 142 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
_logger.NoMatchingWorkflowFoundForPayload();
return false;
Expand Down Expand Up @@ -238,15 +238,15 @@
public void AttachPatientMetaData(TaskExecution task, PatientDetails patientDetails)
{
var attachedData = false;
if (string.IsNullOrWhiteSpace(patientDetails.PatientId) is false)

Check warning on line 241 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
attachedData = task.TaskPluginArguments.TryAdd(PatientKeys.PatientId, patientDetails.PatientId);
}
if (string.IsNullOrWhiteSpace(patientDetails.PatientAge) is false)

Check warning on line 245 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
attachedData = task.TaskPluginArguments.TryAdd(PatientKeys.PatientAge, patientDetails.PatientAge);
}
if (string.IsNullOrWhiteSpace(patientDetails.PatientSex) is false)

Check warning on line 249 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
attachedData = task.TaskPluginArguments.TryAdd(PatientKeys.PatientSex, patientDetails.PatientSex);
}
Expand All @@ -255,11 +255,11 @@
{
attachedData = task.TaskPluginArguments.TryAdd(PatientKeys.PatientDob, patientDob.Value.ToString("o", CultureInfo.InvariantCulture));
}
if (string.IsNullOrWhiteSpace(patientDetails.PatientHospitalId) is false)

Check warning on line 258 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
attachedData = task.TaskPluginArguments.TryAdd(PatientKeys.PatientHospitalId, patientDetails.PatientHospitalId);
}
if (string.IsNullOrWhiteSpace(patientDetails.PatientName) is false)

Check warning on line 262 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
attachedData = task.TaskPluginArguments.TryAdd(PatientKeys.PatientName, patientDetails.PatientName);
}
Expand All @@ -283,7 +283,7 @@
return false;
}

var currentTask = workflowInstance.Tasks.FirstOrDefault(t => t.TaskId == message.TaskId);

Check warning on line 286 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

"Find" method should be used instead of the "FirstOrDefault" extension method. (https://rules.sonarsource.com/csharp/RSPEC-6602)

using var loggingScope = _logger.BeginScope(new Dictionary<string, object>
{
Expand Down Expand Up @@ -346,7 +346,7 @@

var isValid = await HandleOutputArtifacts(workflowInstance, message.Outputs, currentTask, workflow);

if (isValid is false)

Check warning on line 349 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
return await CompleteTask(currentTask, workflowInstance, message.CorrelationId, TaskExecutionStatus.Failed);
}
Expand Down Expand Up @@ -482,6 +482,7 @@

return true;
}

private async Task HandleExternalAppAsync(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string correlationId)
{
var plugins = _migExternalAppPlugins;
Expand Down Expand Up @@ -524,7 +525,6 @@

return;
}

await DispatchDicomExport(workflowInstance, task, exportList, artifactValues, correlationId, plugins);
}

Expand Down Expand Up @@ -563,6 +563,7 @@
return false;
}

_logger.LogMigExport(task.TaskId, string.Join(",", exportDestinations), artifactValues.Length, string.Join(",", plugins));
await ExportRequest(workflowInstance, task, exportDestinations, artifactValues, correlationId, plugins);
return await _workflowInstanceRepository.UpdateTaskStatusAsync(workflowInstance.Id, task.TaskId, TaskExecutionStatus.Dispatched);
}
Expand Down Expand Up @@ -812,6 +813,7 @@
var exportRequestEvent = EventMapper.GenerateTaskCancellationEvent("", taskExec.ExecutionId, workflowInstance.Id, taskExec.TaskId, FailureReason.TimedOut, "Timed out");
var jsonMesssage = new JsonMessage<TaskCancellationEvent>(exportRequestEvent, MessageBrokerConfiguration.WorkflowManagerApplicationId, correlationId, Guid.NewGuid().ToString());

_logger.TaskTimedOut(taskExec.TaskId, workflowInstance.Id, taskExec.Timeout);
await _messageBrokerPublisherService.Publish(TaskTimeoutRoutingKey, jsonMesssage.ToMessage());
return true;
}
Expand Down
39 changes: 21 additions & 18 deletions src/WorkflowManager/WorkflowManager/appsettings.Local.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,25 @@
"scuAgentName": "monaiscu"
}
},
"dicomTagsDisallowed": "PatientName,PatientID,IssuerOfPatientID,TypeOfPatientID,IssuerOfPatientIDQualifiersSequence,SourcePatientGroupIdentificationSequence,GroupOfPatientsIdentificationSequence,SubjectRelativePositionInImage,PatientBirthDate,PatientBirthTime,PatientBirthDateInAlternativeCalendar,PatientDeathDateInAlternativeCalendar,PatientAlternativeCalendar,PatientSex,PatientInsurancePlanCodeSequence,PatientPrimaryLanguageCodeSequence,PatientPrimaryLanguageModifierCodeSequence,QualityControlSubject,QualityControlSubjectTypeCodeSequence,StrainDescription,StrainNomenclature,StrainStockNumber,StrainSourceRegistryCodeSequence,StrainStockSequence,StrainSource,StrainAdditionalInformation,StrainCodeSequence,GeneticModificationsSequence,GeneticModificationsDescription,GeneticModificationsNomenclature,GeneticModificationsCodeSequence,OtherPatientIDsRETIRED,OtherPatientNames,OtherPatientIDsSequence,PatientBirthName,PatientAge,PatientSize,PatientSizeCodeSequence,PatientBodyMassIndex,MeasuredAPDimension,MeasuredLateralDimension,PatientWeight,PatientAddress,InsurancePlanIdentificationRETIRED,PatientMotherBirthName,MilitaryRank,BranchOfService,MedicalRecordLocatorRETIRED,ReferencedPatientPhotoSequence,MedicalAlerts,Allergies,CountryOfResidence,RegionOfResidence,PatientTelephoneNumbers,PatientTelecomInformation,EthnicGroup,Occupation,SmokingStatus,AdditionalPatientHistory,PregnancyStatus,LastMenstrualDate,PatientReligiousPreference,PatientSpeciesDescription,PatientSpeciesCodeSequence,PatientSexNeutered,AnatomicalOrientationType,PatientBreedDescription,PatientBreedCodeSequence,BreedRegistrationSequence,BreedRegistrationNumber,BreedRegistryCodeSequence,ResponsiblePerson,ResponsiblePersonRole,ResponsibleOrganization,PatientComments,ExaminedBodyThickness"
},
"InformaticsGateway": {
"apiHost": "http://localhost:5010",
"username": "aide",
"password": "example"
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5000"
}
"dicomTagsDisallowed": "PatientName,PatientID,IssuerOfPatientID,TypeOfPatientID,IssuerOfPatientIDQualifiersSequence,SourcePatientGroupIdentificationSequence,GroupOfPatientsIdentificationSequence,SubjectRelativePositionInImage,PatientBirthDate,PatientBirthTime,PatientBirthDateInAlternativeCalendar,PatientDeathDateInAlternativeCalendar,PatientAlternativeCalendar,PatientSex,PatientInsurancePlanCodeSequence,PatientPrimaryLanguageCodeSequence,PatientPrimaryLanguageModifierCodeSequence,QualityControlSubject,QualityControlSubjectTypeCodeSequence,StrainDescription,StrainNomenclature,StrainStockNumber,StrainSourceRegistryCodeSequence,StrainStockSequence,StrainSource,StrainAdditionalInformation,StrainCodeSequence,GeneticModificationsSequence,GeneticModificationsDescription,GeneticModificationsNomenclature,GeneticModificationsCodeSequence,OtherPatientIDsRETIRED,OtherPatientNames,OtherPatientIDsSequence,PatientBirthName,PatientAge,PatientSize,PatientSizeCodeSequence,PatientBodyMassIndex,MeasuredAPDimension,MeasuredLateralDimension,PatientWeight,PatientAddress,InsurancePlanIdentificationRETIRED,PatientMotherBirthName,MilitaryRank,BranchOfService,MedicalRecordLocatorRETIRED,ReferencedPatientPhotoSequence,MedicalAlerts,Allergies,CountryOfResidence,RegionOfResidence,PatientTelephoneNumbers,PatientTelecomInformation,EthnicGroup,Occupation,SmokingStatus,AdditionalPatientHistory,PregnancyStatus,LastMenstrualDate,PatientReligiousPreference,PatientSpeciesDescription,PatientSpeciesCodeSequence,PatientSexNeutered,AnatomicalOrientationType,PatientBreedDescription,PatientBreedCodeSequence,BreedRegistrationSequence,BreedRegistrationNumber,BreedRegistryCodeSequence,ResponsiblePerson,ResponsiblePersonRole,ResponsibleOrganization,PatientComments,ExaminedBodyThickness",
"migExternalAppPlugins": [
"Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution.DicomDeidentifier, Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution, Version=0.0.0.0"
],
"InformaticsGateway": {
"apiHost": "http://localhost:5010",
"username": "aide",
"password": "example"
},
"LogHttpRequestQuery": false,
"LogHttpRequestBody": false,
"LogHttpResponseBody": true
},
"AllowedHosts": "*"
}
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5000"
}
},
"LogHttpRequestQuery": false,
"LogHttpRequestBody": false,
"LogHttpResponseBody": true
},
"AllowedHosts": "*"
}
}
2 changes: 1 addition & 1 deletion src/WorkflowManager/WorkflowManager/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
},
"dicomTagsDisallowed": "PatientName,PatientID,IssuerOfPatientID,TypeOfPatientID,IssuerOfPatientIDQualifiersSequence,SourcePatientGroupIdentificationSequence,GroupOfPatientsIdentificationSequence,SubjectRelativePositionInImage,PatientBirthDate,PatientBirthTime,PatientBirthDateInAlternativeCalendar,PatientDeathDateInAlternativeCalendar,PatientAlternativeCalendar,PatientSex,PatientInsurancePlanCodeSequence,PatientPrimaryLanguageCodeSequence,PatientPrimaryLanguageModifierCodeSequence,QualityControlSubject,QualityControlSubjectTypeCodeSequence,StrainDescription,StrainNomenclature,StrainStockNumber,StrainSourceRegistryCodeSequence,StrainStockSequence,StrainSource,StrainAdditionalInformation,StrainCodeSequence,GeneticModificationsSequence,GeneticModificationsDescription,GeneticModificationsNomenclature,GeneticModificationsCodeSequence,OtherPatientIDsRETIRED,OtherPatientNames,OtherPatientIDsSequence,PatientBirthName,PatientAge,PatientSize,PatientSizeCodeSequence,PatientBodyMassIndex,MeasuredAPDimension,MeasuredLateralDimension,PatientWeight,PatientAddress,InsurancePlanIdentificationRETIRED,PatientMotherBirthName,MilitaryRank,BranchOfService,MedicalRecordLocatorRETIRED,ReferencedPatientPhotoSequence,MedicalAlerts,Allergies,CountryOfResidence,RegionOfResidence,PatientTelephoneNumbers,PatientTelecomInformation,EthnicGroup,Occupation,SmokingStatus,AdditionalPatientHistory,PregnancyStatus,LastMenstrualDate,PatientReligiousPreference,PatientSpeciesDescription,PatientSpeciesCodeSequence,PatientSexNeutered,AnatomicalOrientationType,PatientBreedDescription,PatientBreedCodeSequence,BreedRegistrationSequence,BreedRegistrationNumber,BreedRegistryCodeSequence,ResponsiblePerson,ResponsiblePersonRole,ResponsibleOrganization,PatientComments,ExaminedBodyThickness",
"migExternalAppPlugins": "Monai.Deploy.InformaticsGateway.ExecutionPlugins.ExternalAppOutgoing, Monai.Deploy.InformaticsGateway, Version=0.0.0.0"
"migExternalAppPlugins": [ "Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution.DicomDeidentifier, Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution, Version=0.0.0.0" ]
},
"InformaticsGateway": {
"apiHost": "http://localhost:5010",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public WorkflowExecuterServiceTests()
Topics = new MessageBrokerConfigurationKeys { TaskDispatchRequest = "md.task.dispatch", ExportRequestPrefix = "md.export.request" },
DicomAgents = new DicomAgentConfiguration { DicomWebAgentName = "monaidicomweb" }
},
MigExternalAppPlugins = new List<string> { { "examplePlugin" } }
});
MigExternalAppPlugins = new List<string> { { "examplePlugin" } }.ToArray()
}) ;

_storageConfiguration = Options.Create(new StorageServiceConfiguration() { Settings = new Dictionary<string, string> { { "bucket", "testbucket" }, { "endpoint", "localhost" }, { "securedConnection", "False" } } });

Expand Down
Loading