Skip to content

Commit 5f027fa

Browse files
committed
clean up
1 parent 5341908 commit 5f027fa

File tree

7 files changed

+39
-37
lines changed

7 files changed

+39
-37
lines changed

Microsoft.Azure.Cosmos/src/Telemetry/ClientTelemetry.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ internal class ClientTelemetry : IDisposable
4444

4545
private Task telemetryTask;
4646

47-
private ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)> operationInfoMap
48-
= new ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)>();
47+
private ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)> operationInfoMap
48+
= new ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)>();
4949

5050
private ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram> cacheRefreshInfoMap
5151
= new ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram>();
@@ -175,8 +175,8 @@ private async Task EnrichAndSendAsync()
175175
this.clientTelemetryInfo.IsDirectConnectionMode);
176176

177177
// Take the copy for further processing i.e. serializing and dividing into chunks
178-
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)> operationInfoSnapshot
179-
= Interlocked.Exchange(ref this.operationInfoMap, new ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)>());
178+
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)> operationInfoSnapshot
179+
= Interlocked.Exchange(ref this.operationInfoMap, new ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)>());
180180

181181
ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram> cacheRefreshInfoSnapshot
182182
= Interlocked.Exchange(ref this.cacheRefreshInfoMap, new ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram>());
@@ -309,14 +309,13 @@ internal void CollectOperationInfo(CosmosDiagnostics cosmosDiagnostics,
309309
statusCode: (int)statusCode,
310310
subStatusCode: (int)subStatusCode);
311311

312-
(LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int requestDropCount) = this.operationInfoMap
312+
(LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge) = this.operationInfoMap
313313
.GetOrAdd(payloadKey, x => (latency: new LongConcurrentHistogram(ClientTelemetryOptions.RequestLatencyMin,
314314
ClientTelemetryOptions.RequestLatencyMax,
315315
ClientTelemetryOptions.RequestLatencyPrecision),
316316
requestcharge: new LongConcurrentHistogram(ClientTelemetryOptions.RequestChargeMin,
317317
ClientTelemetryOptions.RequestChargeMax,
318-
ClientTelemetryOptions.RequestChargePrecision),
319-
droppedRequestCount: 0));
318+
ClientTelemetryOptions.RequestChargePrecision)));
320319
try
321320
{
322321
latency.RecordValue(cosmosDiagnostics.GetClientElapsedTime().Ticks);

Microsoft.Azure.Cosmos/src/Telemetry/ClientTelemetryPayloadWriter.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static class ClientTelemetryPayloadWriter
1919
{
2020
public static async Task SerializedPayloadChunksAsync(
2121
ClientTelemetryProperties properties,
22-
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)> operationInfoSnapshot,
22+
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)> operationInfoSnapshot,
2323
ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram> cacheRefreshInfoSnapshot,
2424
List<RequestInfo> sampledRequestInfo,
2525
Func<string, Task> callback)
@@ -35,7 +35,7 @@ public static async Task SerializedPayloadChunksAsync(
3535

3636
if (operationInfoSnapshot?.Any() == true)
3737
{
38-
foreach (KeyValuePair<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)> entry in operationInfoSnapshot)
38+
foreach (KeyValuePair<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)> entry in operationInfoSnapshot)
3939
{
4040
long lengthNow = stringBuilder.Length;
4141

@@ -46,19 +46,11 @@ public static async Task SerializedPayloadChunksAsync(
4646
OperationInfo payloadForRequestCharge = payloadForLatency.Copy();
4747
payloadForRequestCharge.MetricInfo = new MetricInfo(ClientTelemetryOptions.RequestChargeName, ClientTelemetryOptions.RequestChargeUnit);
4848
payloadForRequestCharge.SetAggregators(entry.Value.requestcharge, ClientTelemetryOptions.HistogramPrecisionFactor);
49-
50-
OperationInfo payloadForDroppedRntbdRequests = payloadForLatency.Copy();
51-
payloadForRequestCharge.MetricInfo
52-
= new MetricInfo(
53-
metricsName: ClientTelemetryOptions.DroppedRntbdRequestsName,
54-
unitName: ClientTelemetryOptions.DroppedRntbdRequestsUnit,
55-
count: entry.Value.droppedRequestCount);
5649

5750
string latencyMetrics = JsonConvert.SerializeObject(payloadForLatency);
5851
string requestChargeMetrics = JsonConvert.SerializeObject(payloadForRequestCharge);
59-
string droppedRntbdRequestsMetrics = JsonConvert.SerializeObject(payloadForDroppedRntbdRequests);
6052

61-
int thisSectionLength = latencyMetrics.Length + requestChargeMetrics.Length + droppedRntbdRequestsMetrics.Length;
53+
int thisSectionLength = latencyMetrics.Length + requestChargeMetrics.Length;
6254
if (lengthNow + thisSectionLength > ClientTelemetryOptions.PayloadSizeThreshold)
6355
{
6456
writer.WriteEndArray();
@@ -71,7 +63,6 @@ public static async Task SerializedPayloadChunksAsync(
7163

7264
writer.WriteRawValue(latencyMetrics);
7365
writer.WriteRawValue(requestChargeMetrics);
74-
writer.WriteRawValue(droppedRntbdRequestsMetrics);
7566
}
7667

7768
}

Microsoft.Azure.Cosmos/src/Telemetry/ClientTelemetryProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal ClientTelemetryProcessor(CosmosHttpClient httpClient, AuthorizationToke
3636
/// <returns>Task</returns>
3737
internal async Task ProcessAndSendAsync(
3838
ClientTelemetryProperties clientTelemetryInfo,
39-
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedRequestCount)> operationInfoSnapshot,
39+
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharget)> operationInfoSnapshot,
4040
ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram> cacheRefreshInfoSnapshot,
4141
List<RequestInfo> requestInfoSnapshot,
4242
CancellationToken cancellationToken)

Microsoft.Azure.Cosmos/src/Telemetry/Models/RequestInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal sealed class RequestInfo
2626
[JsonProperty("resource")]
2727
public string Resource { get; set; }
2828

29-
[JsonProperty("statusCode")]
29+
[JsonProperty("statusCode")]
3030
public int? StatusCode { get; set; }
3131

3232
[JsonProperty("subStatusCode")]

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/ClientTelemetryTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ public async Task CheckIfPayloadIsDividedCorrectlyAsync(int expectedOperationInf
161161
MockCosmosUtil.CreateCosmosHttpClient(() => new HttpClient(new HttpHandlerHelper(mockHttpHandler.Object))),
162162
Mock.Of<AuthorizationTokenProvider>());
163163

164-
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedrequestCount)> operationInfoSnapshot
165-
= new ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge, int droppedrequestCount)> ();
164+
ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)> operationInfoSnapshot
165+
= new ConcurrentDictionary<OperationInfo, (LongConcurrentHistogram latency, LongConcurrentHistogram requestcharge)> ();
166166

167167
int numberOfMetricsInOperatiionSection = 3;
168168
for (int i = 0; i < (expectedOperationInfoSize/ numberOfMetricsInOperatiionSection); i++)
@@ -187,7 +187,7 @@ public async Task CheckIfPayloadIsDividedCorrectlyAsync(int expectedOperationInf
187187
ClientTelemetryOptions.RequestChargePrecision);
188188
requestcharge.RecordValue(11);
189189

190-
operationInfoSnapshot.TryAdd(opeInfo, (latency, requestcharge, 100));
190+
operationInfoSnapshot.TryAdd(opeInfo, (latency, requestcharge));
191191
}
192192

193193
ConcurrentDictionary<CacheRefreshInfo, LongConcurrentHistogram> cacheRefreshInfoSnapshot

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DataSamplerTests.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ namespace Microsoft.Azure.Cosmos.Tests.Telemetry
1414
[TestClass]
1515
public class DataSamplerTests
1616
{
17-
/* [TestMethod]
18-
[DataRow(200, 0, 1, false)]
19-
[DataRow(404, 0, 1, false)]
20-
[DataRow(404, 1002, 1, true)]
21-
[DataRow(409, 0, 1, false)]
22-
[DataRow(409, 1002, 1, true)]
23-
[DataRow(503, 2001, 1, true)]
24-
[DataRow(200, 0, 6, true)]
25-
public void CheckEligibleStatistics(int statusCode, int subStatusCode, int latencyInMs, bool expectedFlag)
26-
{
27-
Assert.AreEqual(expectedFlag, NetworkRequestSampler.IsEligible(statusCode, subStatusCode, TimeSpan.FromMilliseconds(latencyInMs)));
28-
}*/
29-
3017
[TestMethod]
3118
[DataRow(10)]
3219
public void TestNetworkRequestSamplerForThreshold(int threshold)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//------------------------------------------------------------
4+
5+
namespace Microsoft.Azure.Cosmos.Tests.Telemetry
6+
{
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
using Microsoft.Azure.Cosmos.Telemetry;
13+
using Microsoft.VisualStudio.TestTools.UnitTesting;
14+
15+
[TestClass]
16+
public class NetworkDataRecorderTest
17+
{
18+
[TestMethod]
19+
public void TestRecordWithErroredAndHighLatencyRequests()
20+
{
21+
NetworkDataRecorder recorder = new NetworkDataRecorder();
22+
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)