Skip to content

Commit

Permalink
fix retrieve metric (#3044)
Browse files Browse the repository at this point in the history
do not emit MaxFileSize and use first instance's properties to see if it has metadata
  • Loading branch information
esmadau authored Sep 15, 2023
1 parent 521b58d commit a8f99f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task<RetrieveRenderedResponse> RetrieveRenderedImageAsync(RetrieveR
"Retrieving rendered Instance for watermark {Watermark} of size {ContentLength}", instance.VersionedInstanceIdentifier.Version, fileProperties.ContentLength);
_retrieveMeter.RetrieveInstanceCount.Add(
1,
RetrieveMeter.RetrieveInstanceCountTelemetryDimension(fileProperties.ContentLength, _retrieveConfiguration.MaxDicomFileSize, isRendered: true));
RetrieveMeter.RetrieveInstanceCountTelemetryDimension(fileProperties.ContentLength, isRendered: true));

using Stream stream = await _blobDataStore.GetFileAsync(instance.VersionedInstanceIdentifier.Version, instance.VersionedInstanceIdentifier.Partition.Name, cancellationToken);
sw.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public async Task<RetrieveResourceResponse> GetInstanceResourceAsync(RetrieveRes
}

// no transcoding
IAsyncEnumerable<RetrieveResourceInstance> responses = GetAsyncEnumerableStreams(retrieveInstances, isOriginalTransferSyntaxRequested, requestedTransferSyntax, message.IsOriginalVersionRequested, version, cancellationToken);
IAsyncEnumerable<RetrieveResourceInstance> responses = GetAsyncEnumerableStreams(retrieveInstances, isOriginalTransferSyntaxRequested, requestedTransferSyntax, message.IsOriginalVersionRequested, version, instance.InstanceProperties.HasFrameMetadata, cancellationToken);
return new RetrieveResourceResponse(responses, validAcceptHeader.MediaType.ToString(), validAcceptHeader.IsSinglePart);
}
catch (DataStoreException e)
Expand Down Expand Up @@ -252,7 +252,7 @@ private void LogFileSize(long size, long version, bool needsTranscoding, bool ha
version, size, needsTranscoding);
_retrieveMeter.RetrieveInstanceCount.Add(
1,
RetrieveMeter.RetrieveInstanceCountTelemetryDimension(size, _retrieveConfiguration.MaxDicomFileSize, isTranscoding: needsTranscoding, hasFrameMetadata: hasFrameMetadata));
RetrieveMeter.RetrieveInstanceCountTelemetryDimension(size, isTranscoding: needsTranscoding, hasFrameMetadata: hasFrameMetadata));
}

private void SetTranscodingBillingProperties(long bytesTranscoded)
Expand Down Expand Up @@ -297,6 +297,7 @@ private async IAsyncEnumerable<RetrieveResourceInstance> GetAsyncEnumerableStrea
string requestedTransferSyntax,
bool isOriginalVersionRequested,
long requestedVersion,
bool hasFrameMetadata,
[EnumeratorCancellation] CancellationToken cancellationToken)
{
long streamTotalLength = 0;
Expand All @@ -312,7 +313,7 @@ private async IAsyncEnumerable<RetrieveResourceInstance> GetAsyncEnumerableStrea
GetResponseTransferSyntax(isOriginalTransferSyntaxRequested, requestedTransferSyntax, instanceMetadata),
fileProperties.ContentLength);
}
LogFileSize(streamTotalLength, requestedVersion, needsTranscoding: false, hasFrameMetadata: true);
LogFileSize(streamTotalLength, requestedVersion, needsTranscoding: false, hasFrameMetadata: hasFrameMetadata);
}

private static async IAsyncEnumerable<RetrieveResourceInstance> GetAsyncEnumerableFrameStreams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ public RetrieveMeter()

public Counter<long> RetrieveInstanceCount { get; }

public static KeyValuePair<string, object>[] RetrieveInstanceCountTelemetryDimension(long contentLength, long maxFileSize, bool isTranscoding = false, bool hasFrameMetadata = false, bool isRendered = false) =>
public static KeyValuePair<string, object>[] RetrieveInstanceCountTelemetryDimension(long contentLength, bool isTranscoding = false, bool hasFrameMetadata = false, bool isRendered = false) =>
new[]
{
new KeyValuePair<string, object>("ContentLength", contentLength),
new KeyValuePair<string, object>("MaxFileSize", maxFileSize),
new KeyValuePair<string, object>("IsTranscoding", isTranscoding),
new KeyValuePair<string, object>("IsRendered", isRendered),
new KeyValuePair<string, object>("HasFrameMetadata", hasFrameMetadata),
Expand Down

0 comments on commit a8f99f3

Please sign in to comment.