From 340ac5c37abcbc70820bb6b7bb0c84aceca3aa3d Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Tue, 28 Mar 2023 03:31:57 +0530 Subject: [PATCH] added more comments --- .../src/Telemetry/Sampler/DataSampler.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/Sampler/DataSampler.cs b/Microsoft.Azure.Cosmos/src/Telemetry/Sampler/DataSampler.cs index da2da792d9..071e440945 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/Sampler/DataSampler.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/Sampler/DataSampler.cs @@ -26,11 +26,13 @@ public static List OrderAndSample(List requestInfoList foreach (RequestInfo requestInfo in requestInfoList) { + // Get a unique key identifier for an object int key = requestInfo.GetHashCodeForSampler(); // Check if similar object is already present if (sampledRawData.TryGetValue(key, out List> sortedData)) { + // Add the new object to the list DataSampler.AddToList(orderBy, requestInfo, sortedData); sortedData.Sort(DataComparer.Instance); @@ -67,18 +69,21 @@ List> newSortedData private static void AddToList(DataSamplerOrderBy orderBy, RequestInfo requestInfo, List> sortedData) { + double valueToStore; if (orderBy == DataSamplerOrderBy.Latency) { - sortedData.Add(new KeyValuePair(requestInfo.GetP99Latency(), requestInfo)); + valueToStore = requestInfo.GetP99Latency(); } else if (orderBy == DataSamplerOrderBy.SampleCount) { - sortedData.Add(new KeyValuePair(requestInfo.GetSampleCount(), requestInfo)); + valueToStore = requestInfo.GetSampleCount(); } else { throw new Exception("order by not supported. Only Supported values are Latency, SampleCount"); } + + sortedData.Add(new KeyValuePair(valueToStore, requestInfo)); } }