Skip to content

Commit

Permalink
cleanup dicom cast logging to match dicom service (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullah248 authored Jan 5, 2022
1 parent de06ccc commit b4ea22f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public async Task ProcessAsync(TimeSpan pollIntervalDuringCatchup, CancellationT
{
if (ex is FhirNonRetryableException || ex is DicomTagException || ex is TimeoutRejectedException)
{
string studyUid = changeFeedEntry.StudyInstanceUid;
string seriesUid = changeFeedEntry.SeriesInstanceUid;
string instanceUid = changeFeedEntry.SopInstanceUid;
string studyInstanceUid = changeFeedEntry.StudyInstanceUid;
string seriesInstanceUid = changeFeedEntry.SeriesInstanceUid;
string sopInstanceUid = changeFeedEntry.SopInstanceUid;
long changeFeedSequence = changeFeedEntry.Sequence;

ErrorType errorType = ErrorType.FhirError;
Expand All @@ -114,7 +114,7 @@ await _exceptionStore.WriteExceptionAsync(
errorType,
cancellationToken);

_logger.LogError("Failed to process DICOM event with SequenceID: {SequenceId}, StudyUid: {StudyUid}, SeriesUid: {SeriesUid}, instanceUid: {InstanceUid} and will not be retried further. Continuing to next event.", changeFeedEntry.Sequence, studyUid, seriesUid, instanceUid);
_logger.LogError("Failed to process DICOM event with SequenceID: {SequenceId}, StudyUid: {StudyInstanceUid}, SeriesUid: {SeriesInstanceUid}, instanceUid: {SopInstanceUid} and will not be retried further. Continuing to next event.", changeFeedEntry.Sequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ public async Task WriteExceptionAsync(ChangeFeedEntry changeFeedEntry, Exception
}

DicomDataset dataset = changeFeedEntry.Metadata;
string studyUid = dataset.GetSingleValue<string>(DicomTag.StudyInstanceUID);
string seriesUid = dataset.GetSingleValue<string>(DicomTag.SeriesInstanceUID);
string instanceUid = dataset.GetSingleValue<string>(DicomTag.SOPInstanceUID);
string studyInstanceUid = dataset.GetSingleValue<string>(DicomTag.StudyInstanceUID);
string seriesInstanceUid = dataset.GetSingleValue<string>(DicomTag.SeriesInstanceUID);
string sopInstanceUid = dataset.GetSingleValue<string>(DicomTag.SOPInstanceUID);
long changeFeedSequence = changeFeedEntry.Sequence;

var tableClient = _tableServiceClient.GetTableClient(tableName);
var entity = new IntransientEntity(studyUid, seriesUid, instanceUid, changeFeedSequence, exceptionToStore);
var entity = new IntransientEntity(studyInstanceUid, seriesInstanceUid, sopInstanceUid, changeFeedSequence, exceptionToStore);

try
{
await tableClient.UpsertEntityAsync(entity, cancellationToken: cancellationToken);
_logger.LogInformation("Error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Stored into table: {Table} in table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, tableName);
_logger.LogInformation("Error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyInstanceUid}, SeriesUID: {SeriesInstanceUid}, InstanceUID: {SopInstanceUid}. Stored into table: {Table} in table storage.", changeFeedSequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid, tableName);
}
catch
{
_logger.LogInformation("Error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Failed to store to table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid);
_logger.LogInformation("Error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyInstanceUid}, SeriesUID: {SeriesInstanceUid}, InstanceUID: {SopInstanceUid}. Failed to store to table storage.", changeFeedSequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
throw;
}
}
Expand All @@ -80,22 +80,22 @@ public async Task WriteRetryableExceptionAsync(ChangeFeedEntry changeFeedEntry,
EnsureArg.IsNotNull(changeFeedEntry, nameof(changeFeedEntry));

DicomDataset dataset = changeFeedEntry.Metadata;
string studyUid = dataset.GetSingleValue<string>(DicomTag.StudyInstanceUID);
string seriesUid = dataset.GetSingleValue<string>(DicomTag.SeriesInstanceUID);
string instanceUid = dataset.GetSingleValue<string>(DicomTag.SOPInstanceUID);
string studyInstanceUid = dataset.GetSingleValue<string>(DicomTag.StudyInstanceUID);
string seriesInstanceUid = dataset.GetSingleValue<string>(DicomTag.SeriesInstanceUID);
string sopInstanceUid = dataset.GetSingleValue<string>(DicomTag.SOPInstanceUID);
long changeFeedSequence = changeFeedEntry.Sequence;

var tableClient = _tableServiceClient.GetTableClient(Constants.TransientRetryTableName);
var entity = new RetryableEntity(studyUid, seriesUid, instanceUid, changeFeedSequence, retryNum, exceptionToStore);
var entity = new RetryableEntity(studyInstanceUid, seriesInstanceUid, sopInstanceUid, changeFeedSequence, retryNum, exceptionToStore);

try
{
await tableClient.UpsertEntityAsync(entity, cancellationToken: cancellationToken);
_logger.LogInformation("Retryable error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Tried {RetryNum} time(s). Waiting {Milliseconds} milliseconds . Stored into table: {Table} in table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, retryNum, nextDelayTimeSpan.TotalMilliseconds, Constants.TransientRetryTableName);
_logger.LogInformation("Retryable error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyInstanceUid}, SeriesUID: {SeriesInstanceUid}, InstanceUID: {SopInstanceUid}. Tried {RetryNum} time(s). Waiting {Milliseconds} milliseconds . Stored into table: {Table} in table storage.", changeFeedSequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid, retryNum, nextDelayTimeSpan.TotalMilliseconds, Constants.TransientRetryTableName);
}
catch
{
_logger.LogInformation("Retryable error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Tried {RetryNum} time(s). Failed to store to table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, retryNum);
_logger.LogInformation("Retryable error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyInstanceUid}, SeriesUID: {SeriesInstanceUid}, InstanceUID: {SopInstanceUid}. Tried {RetryNum} time(s). Failed to store to table storage.", changeFeedSequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid, retryNum);
throw;
}
}
Expand Down

0 comments on commit b4ea22f

Please sign in to comment.