From a1ab372dc4a62b77aec67d7c280051d60f532ce8 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 18 Apr 2024 07:52:00 +0530 Subject: [PATCH 01/11] Added Request charge and Payload size options to generate request diagnostics --- .../src/CosmosThresholdOptions.cs | 36 +++++++++++++-- .../OpenTelemetry/CosmosDbEventSource.cs | 46 +++++++++++++++---- .../Filters/DiagnosticsFilterHelper.cs | 16 +++---- .../Telemetry/DiagnosticsFilterHelperTest.cs | 2 +- 4 files changed, 78 insertions(+), 22 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs index b4f59d25f0..e59827752a 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs @@ -7,20 +7,50 @@ namespace Microsoft.Azure.Cosmos using System; /// - /// Threshold values for Distributed Tracing + /// This class describes the thresholds when more details diagnostics are emitted for an operation due to high latency, + /// high RU consumption or high payload sizes. /// public class CosmosThresholdOptions { /// - /// Latency Threshold for non point operations i.e. Query + /// Can be used to define custom latency thresholds. When the latency threshold is exceeded more detailed + /// diagnostics will be emitted (including the request diagnostics). There is some overhead of emitting the + /// more detailed diagnostics - so recommendation is to choose latency thresholds that reduce the noise level + /// and only emit detailed diagnostics when there is really business impact seen. + /// The default value for the point operation latency threshold is 3 seconds. + /// all operations except (ReadItem, CreateItem, UpsertItem, ReplaceItem, PatchItem or DeleteItem) /// /// 3 seconds public TimeSpan NonPointOperationLatencyThreshold { get; set; } = TimeSpan.FromSeconds(3); /// - /// Latency Threshold for point operations i.e operation other than Query + /// Can be used to define custom latency thresholds. When the latency threshold is exceeded more detailed + /// diagnostics will be emitted (including the request diagnostics). There is some overhead of emitting the + /// more detailed diagnostics - so recommendation is to choose latency thresholds that reduce the noise level + /// and only emit detailed diagnostics when there is really business impact seen. + /// The default value for the point operation latency threshold is 1 second. + /// Point Operations are: (ReadItem, CreateItem, UpsertItem, ReplaceItem, PatchItem or DeleteItem) /// /// 1 second public TimeSpan PointOperationLatencyThreshold { get; set; } = TimeSpan.FromSeconds(1); + + /// + /// Can be used to define a custom RU (request charge) threshold. When the threshold is exceeded more detailed + /// diagnostics will be emitted (including the request diagnostics). There is some overhead of emitting the + /// more detailed diagnostics - so recommendation is to choose a request charge threshold that reduces the noise + /// level and only emits detailed diagnostics when the request charge is significantly higher thane expected. + /// The default value for the request charge threshold is 1000 + /// + public double RequestChargeThreshold { get; set; } = 1000; + + /// + /// Can be used to define a payload size threshold. When the threshold is exceeded for either request or + /// response payloads more detailed diagnostics will be emitted (including the request diagnostics). + /// There is some overhead of emitting the more detailed diagnostics - so recommendation is to choose a + /// payload size threshold that reduces the noise level and only emits detailed diagnostics when the payload size + /// is significantly higher than expected. + /// The default value for the payload size threshold is Int32.MaxValue + /// + public int PayloadSizeThresholdInBytes { get; set; } = Int32.MaxValue; } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs index f7fe0c307f..f6d47b8d02 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs @@ -4,6 +4,7 @@ namespace Microsoft.Azure.Cosmos.Telemetry { + using System; using System.Diagnostics.Tracing; using global::Azure.Core.Diagnostics; using Microsoft.Azure.Cosmos.Telemetry.Diagnostics; @@ -35,17 +36,30 @@ public static void RecordDiagnosticsForRequests( Documents.OperationType operationType, OpenTelemetryAttributes response) { - if (!DiagnosticsFilterHelper.IsSuccessfulResponse( - response.StatusCode, response.SubStatusCode) && CosmosDbEventSource.IsEnabled(EventLevel.Warning)) + if (CosmosDbEventSource.IsEnabled(EventLevel.Warning)) { - CosmosDbEventSource.Singleton.FailedRequest(response.Diagnostics.ToString()); - } - else if (DiagnosticsFilterHelper.IsLatencyThresholdCrossed( - config: config, - operationType: operationType, - response: response) && CosmosDbEventSource.IsEnabled(EventLevel.Warning)) - { - CosmosDbEventSource.Singleton.LatencyOverThreshold(response.Diagnostics.ToString()); + if (!DiagnosticsFilterHelper.IsSuccessfulResponse( + response.StatusCode, response.SubStatusCode)) + { + CosmosDbEventSource.Singleton.FailedRequest(response.Diagnostics.ToString()); + } + else if (DiagnosticsFilterHelper.IsLatencyThresholdCrossed( + config: config, + operationType: operationType, + response: response)) + { + CosmosDbEventSource.Singleton.LatencyOverThreshold(response.Diagnostics.ToString()); + } + else if (config.RequestChargeThreshold <= response.RequestCharge) + { + CosmosDbEventSource.Singleton.RequestChargeOverThreshold(response.Diagnostics.ToString()); + } + else if (config.PayloadSizeThresholdInBytes <= + Math.Max(Convert.ToInt32(response.RequestContentLength), + Convert.ToInt32(response.ResponseContentLength))) + { + CosmosDbEventSource.Singleton.PayloadSizeOverThreshold(response.Diagnostics.ToString()); + } } } @@ -75,5 +89,17 @@ private void FailedRequest(string message) { this.WriteEvent(3, message); } + + [Event(4, Level = EventLevel.Warning)] + private void RequestChargeOverThreshold(string message) + { + this.WriteEvent(4, message); + } + + [Event(5, Level = EventLevel.Warning)] + private void PayloadSizeOverThreshold(string message) + { + this.WriteEvent(5, message); + } } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs index 3c0646f101..941bbd6631 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs @@ -21,28 +21,28 @@ public static bool IsLatencyThresholdCrossed( OperationType operationType, OpenTelemetryAttributes response) { - return response.Diagnostics.GetClientElapsedTime() > DiagnosticsFilterHelper.DefaultThreshold(operationType, config); + return response.Diagnostics.GetClientElapsedTime() > DiagnosticsFilterHelper.DefaultLatencyThreshold(operationType, config); } /// /// Check if response HTTP status code is returning successful /// /// true or false - public static bool IsSuccessfulResponse(HttpStatusCode statusCode, int substatusCode) + public static bool IsSuccessfulResponse(HttpStatusCode statusCode, int subStatusCode) { return statusCode.IsSuccess() - || (statusCode == System.Net.HttpStatusCode.NotFound && substatusCode == 0) - || (statusCode == System.Net.HttpStatusCode.NotModified && substatusCode == 0) - || (statusCode == System.Net.HttpStatusCode.Conflict && substatusCode == 0) - || (statusCode == System.Net.HttpStatusCode.PreconditionFailed && substatusCode == 0); + || (statusCode == System.Net.HttpStatusCode.NotFound && subStatusCode == 0) + || (statusCode == System.Net.HttpStatusCode.NotModified && subStatusCode == 0) + || (statusCode == System.Net.HttpStatusCode.Conflict && subStatusCode == 0) + || (statusCode == System.Net.HttpStatusCode.PreconditionFailed && subStatusCode == 0); } /// - /// Get default threshold value based on operation type + /// Get default Latency threshold value based on operation type /// /// /// - internal static TimeSpan DefaultThreshold(OperationType operationType, CosmosThresholdOptions config) + internal static TimeSpan DefaultLatencyThreshold(OperationType operationType, CosmosThresholdOptions config) { config ??= DiagnosticsFilterHelper.defaultThresholdOptions; return DiagnosticsFilterHelper.IsPointOperation(operationType) ? diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs index 62517239e3..e12d2280be 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs @@ -79,7 +79,7 @@ public void CheckedDefaultThresholdBasedOnOperationType() foreach(OperationType operationType in values) { - TimeSpan defaultThreshold = DiagnosticsFilterHelper.DefaultThreshold(operationType, config); + TimeSpan defaultThreshold = DiagnosticsFilterHelper.DefaultLatencyThreshold(operationType, config); if(DiagnosticsFilterHelper.IsPointOperation(operationType)) Assert.AreEqual(defaultThreshold, config.PointOperationLatencyThreshold); From 8300258e51b487a359786d1ffee6cb338a812656 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 18 Apr 2024 07:57:40 +0530 Subject: [PATCH 02/11] Added default values --- Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs index e59827752a..f748144445 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs @@ -41,6 +41,7 @@ public class CosmosThresholdOptions /// level and only emits detailed diagnostics when the request charge is significantly higher thane expected. /// The default value for the request charge threshold is 1000 /// + /// 1000 RU public double RequestChargeThreshold { get; set; } = 1000; /// @@ -51,6 +52,7 @@ public class CosmosThresholdOptions /// is significantly higher than expected. /// The default value for the payload size threshold is Int32.MaxValue /// + /// 2147483647 Bytes public int PayloadSizeThresholdInBytes { get; set; } = Int32.MaxValue; } } From 43d51c7d4ec48ccfb1386407531f085e94f891e5 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 18 Apr 2024 08:08:46 +0530 Subject: [PATCH 03/11] add exception handling for payload size --- .../src/CosmosThresholdOptions.cs | 2 +- .../OpenTelemetry/CosmosDbEventSource.cs | 6 ++-- .../Filters/DiagnosticsFilterHelper.cs | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs index f748144445..37713675a7 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs @@ -52,7 +52,7 @@ public class CosmosThresholdOptions /// is significantly higher than expected. /// The default value for the payload size threshold is Int32.MaxValue /// - /// 2147483647 Bytes + /// 2147483647 Bytes public int PayloadSizeThresholdInBytes { get; set; } = Int32.MaxValue; } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs index f6d47b8d02..6e405c010a 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs @@ -54,9 +54,9 @@ public static void RecordDiagnosticsForRequests( { CosmosDbEventSource.Singleton.RequestChargeOverThreshold(response.Diagnostics.ToString()); } - else if (config.PayloadSizeThresholdInBytes <= - Math.Max(Convert.ToInt32(response.RequestContentLength), - Convert.ToInt32(response.ResponseContentLength))) + else if (DiagnosticsFilterHelper.IsPayloadSizeThresholdCrossed( + config: config, + response: response)) { CosmosDbEventSource.Singleton.PayloadSizeOverThreshold(response.Diagnostics.ToString()); } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs index 941bbd6631..0d0c7019f1 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs @@ -24,6 +24,37 @@ public static bool IsLatencyThresholdCrossed( return response.Diagnostics.GetClientElapsedTime() > DiagnosticsFilterHelper.DefaultLatencyThreshold(operationType, config); } + /// + /// Allow only Payload size(request/response) is more the configured threshold + /// + /// true or false + public static bool IsPayloadSizeThresholdCrossed( + CosmosThresholdOptions config, + OpenTelemetryAttributes response) + { + int requestContentLength = 0; + int responseContentLength = 0; + try + { + requestContentLength = Convert.ToInt32(response.RequestContentLength); + } + catch (Exception) + { + // Ignore, if this conversion fails for any reason. + } + + try + { + responseContentLength = Convert.ToInt32(response.ResponseContentLength); + } + catch (Exception) + { + // Ignore, if this conversion fails for any reason. + } + + return config.PayloadSizeThresholdInBytes <= Math.Max(requestContentLength, responseContentLength); + } + /// /// Check if response HTTP status code is returning successful /// From 0a18a9e86acddc5fbe06054dad8ae9fbc98bd230 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 18 Apr 2024 08:24:37 +0530 Subject: [PATCH 04/11] Added test --- .../Telemetry/DiagnosticsFilterHelperTest.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs index e12d2280be..206ca2fc59 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/DiagnosticsFilterHelperTest.cs @@ -51,6 +51,37 @@ public void CheckReturnFalseOnSuccessAndLowerLatencyThanConfiguredConfig() $"and Is response Success : {response.StatusCode.IsSuccess()}" ); } + [TestMethod] + [DataRow("50", "60", false, DisplayName = "When Request and Response content length is less than threshold.")] + [DataRow("150", "60", true, DisplayName = "When Request content length is greater than threshold but response content length is less than threshold.")] + [DataRow("50", "160", true, DisplayName = "When Request content length is less than threshold but response content length is greater than threshold.")] + [DataRow("150", "160", true, DisplayName = "When Request and Response content length is greater than threshold.")] + [DataRow("Invalid Request Length", "160", true, DisplayName = "When Request content length is 'Invalid' and response content length is greater than threshold.")] + [DataRow("Invalid Request Length", "60", false, DisplayName = "When Request content length is 'Invalid' and response content length is less than threshold.")] + [DataRow("150", "Invalid Response Length", true, DisplayName = "When Request content length is greater than threshold and response content length is 'Invalid'.")] + [DataRow("50", "Invalid Response Length", false, DisplayName = "When Request content length is less than threshold and response content length is 'invalid'.")] + [DataRow(null, "160", true, DisplayName = "When Request content length is 'null' and response content length is greater than threshold.")] + [DataRow(null, "60", false, DisplayName = "When Request content length is 'null' and response content length is less than threshold.")] + [DataRow("150", null, true, DisplayName = "When Request content length is greater than threshold and response content length is 'null'.")] + [DataRow("50", null, false, DisplayName = "When Request content length is less than threshold and response content length is 'null'.")] + public void CheckReturnFalseOnSuccessAndLowerPayloadSizeThanConfiguredConfig(string requestContentLength, string responseContentLength, bool expectedResult) + { + CosmosThresholdOptions distributedTracingOptions = new CosmosThresholdOptions + { + PayloadSizeThresholdInBytes = 100 + }; + + OpenTelemetryAttributes response = new OpenTelemetryAttributes + { + ResponseContentLength = requestContentLength, + RequestContentLength = responseContentLength, + }; + + Assert.AreEqual(expectedResult, + DiagnosticsFilterHelper + .IsPayloadSizeThresholdCrossed(distributedTracingOptions, response)); + } + [TestMethod] public void CheckReturnTrueOnFailedStatusCode() { From da7c0fd347eeb9e79c0a15339abf12940a0a913c Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 18 Apr 2024 08:33:08 +0530 Subject: [PATCH 05/11] update contract file --- .../Contracts/DotNetSDKAPI.json | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json index 63046ce862..84ea3b8bb1 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json @@ -3686,6 +3686,30 @@ "Microsoft.Azure.Cosmos.CosmosThresholdOptions;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": { "Subclasses": {}, "Members": { + "Double get_RequestChargeThreshold()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "Double get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "Double RequestChargeThreshold": { + "Type": "Property", + "Attributes": [], + "MethodInfo": "Double RequestChargeThreshold;CanRead:True;CanWrite:True;Double get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_RequestChargeThreshold(Double);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "Int32 get_PayloadSizeThresholdInBytes()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "Int32 get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "Int32 PayloadSizeThresholdInBytes": { + "Type": "Property", + "Attributes": [], + "MethodInfo": "Int32 PayloadSizeThresholdInBytes;CanRead:True;CanWrite:True;Int32 get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_PayloadSizeThresholdInBytes(Int32);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, "System.TimeSpan get_NonPointOperationLatencyThreshold()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ @@ -3722,12 +3746,26 @@ ], "MethodInfo": "Void set_NonPointOperationLatencyThreshold(System.TimeSpan);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, + "Void set_PayloadSizeThresholdInBytes(Int32)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "Void set_PayloadSizeThresholdInBytes(Int32);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, "Void set_PointOperationLatencyThreshold(System.TimeSpan)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ "CompilerGeneratedAttribute" ], "MethodInfo": "Void set_PointOperationLatencyThreshold(System.TimeSpan);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "Void set_RequestChargeThreshold(Double)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "Void set_RequestChargeThreshold(Double);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" } }, "NestedTypes": {} From dfab0cbae69b185bfc7a68e0ef54b2cea2152669 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Tue, 23 Apr 2024 14:28:32 +0530 Subject: [PATCH 06/11] added docs --- Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs index 37713675a7..b01bb3e4ed 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs @@ -7,7 +7,7 @@ namespace Microsoft.Azure.Cosmos using System; /// - /// This class describes the thresholds when more details diagnostics are emitted for an operation due to high latency, + /// This class describes the thresholds when more details diagnostics events are emitted, if subscribed, for an operation due to high latency, /// high RU consumption or high payload sizes. /// public class CosmosThresholdOptions From 784ee2940b154d6b0ad066bb4f582d579fe50ea1 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Wed, 24 Apr 2024 06:59:23 +0530 Subject: [PATCH 07/11] add null check --- Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs | 10 +++------- .../src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs | 6 ++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs index b01bb3e4ed..3fb6816363 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs @@ -41,18 +41,14 @@ public class CosmosThresholdOptions /// level and only emits detailed diagnostics when the request charge is significantly higher thane expected. /// The default value for the request charge threshold is 1000 /// - /// 1000 RU - public double RequestChargeThreshold { get; set; } = 1000; + public double? RequestChargeThreshold { get; set; } = null; /// /// Can be used to define a payload size threshold. When the threshold is exceeded for either request or /// response payloads more detailed diagnostics will be emitted (including the request diagnostics). /// There is some overhead of emitting the more detailed diagnostics - so recommendation is to choose a /// payload size threshold that reduces the noise level and only emits detailed diagnostics when the payload size - /// is significantly higher than expected. - /// The default value for the payload size threshold is Int32.MaxValue - /// - /// 2147483647 Bytes - public int PayloadSizeThresholdInBytes { get; set; } = Int32.MaxValue; + /// is significantly higher than expected. /// + public int? PayloadSizeThresholdInBytes { get; set; } = null; } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs index 6e405c010a..e3bdfe709d 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs @@ -50,11 +50,13 @@ public static void RecordDiagnosticsForRequests( { CosmosDbEventSource.Singleton.LatencyOverThreshold(response.Diagnostics.ToString()); } - else if (config.RequestChargeThreshold <= response.RequestCharge) + else if (config.RequestChargeThreshold is not null && + config.RequestChargeThreshold <= response.RequestCharge) { CosmosDbEventSource.Singleton.RequestChargeOverThreshold(response.Diagnostics.ToString()); } - else if (DiagnosticsFilterHelper.IsPayloadSizeThresholdCrossed( + else if (config.PayloadSizeThresholdInBytes is not null && + DiagnosticsFilterHelper.IsPayloadSizeThresholdCrossed( config: config, response: response)) { From 712a5d5219d089fca1e9bfb564ba76af7746d057 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Wed, 24 Apr 2024 07:37:29 +0530 Subject: [PATCH 08/11] added more docs --- .../src/CosmosClientTelemetryOptions.cs | 24 ++++++++++++++----- .../src/CosmosThresholdOptions.cs | 6 ++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/CosmosClientTelemetryOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosClientTelemetryOptions.cs index ec16c0f3b8..a8bf4d44d7 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosClientTelemetryOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosClientTelemetryOptions.cs @@ -10,17 +10,30 @@ namespace Microsoft.Azure.Cosmos public class CosmosClientTelemetryOptions { /// - /// Disable sending telemetry to service, is not applicable to this as of now. + /// Disable sending telemetry data to Microsoft, is not applicable for this. /// - /// This option will disable sending telemetry to service.even it is opt-in from portal. + /// This feature has to be enabled at 2 places: + /// + /// Opt-in from portal to subscribe for this feature. + /// Setting this property to false, to enable it for a particular client instance. + /// + /// /// true public bool DisableSendingMetricsToService { get; set; } = true; /// - /// This method enable/disable generation of operation level if listener is subscribed to the Source Name "Azure.Cosmos.Operation". + /// This method enable/disable generation of operation level if listener is subscribed to the Source Name "Azure.Cosmos.Operation"(to capture operation level traces) + /// and "Azure-Cosmos-Operation-Request-Diagnostics"(to capture events with request diagnostics JSON) /// /// false - /// Please Refer https://opentelemetry.io/docs/instrumentation/net/exporters/ to know more about open telemetry exporters + /// + /// You can set different thresholds values by setting . + /// It would generate events with Request Diagnostics JSON, if any of the configured threshold is crossed, otherwise it would always generate events with Request Diagnostics JSON for failed requests. + /// There is some overhead of emitting the more detailed diagnostics - so recommendation is to choose these thresholds that reduce the noise level + /// and only emit detailed diagnostics when there is really business impact seen.

+ /// Refer to know more about open telemetry exporters available.

+ /// Refer to know more about this feature. + ///
public bool DisableDistributedTracing { get; set; } = #if PREVIEW false; @@ -30,9 +43,8 @@ public class CosmosClientTelemetryOptions /// /// Threshold values for Distributed Tracing. - /// These values decides whether to generate operation level with request diagnostics or not. + /// These values decides whether to generate an with request diagnostics or not. /// public CosmosThresholdOptions CosmosThresholdOptions { get; set; } = new CosmosThresholdOptions(); - } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs index 3fb6816363..3eb768f71b 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs @@ -38,8 +38,7 @@ public class CosmosThresholdOptions /// Can be used to define a custom RU (request charge) threshold. When the threshold is exceeded more detailed /// diagnostics will be emitted (including the request diagnostics). There is some overhead of emitting the /// more detailed diagnostics - so recommendation is to choose a request charge threshold that reduces the noise - /// level and only emits detailed diagnostics when the request charge is significantly higher thane expected. - /// The default value for the request charge threshold is 1000 + /// level and only emits detailed diagnostics when the request charge is significantly higher than expected. /// public double? RequestChargeThreshold { get; set; } = null; @@ -48,7 +47,8 @@ public class CosmosThresholdOptions /// response payloads more detailed diagnostics will be emitted (including the request diagnostics). /// There is some overhead of emitting the more detailed diagnostics - so recommendation is to choose a /// payload size threshold that reduces the noise level and only emits detailed diagnostics when the payload size - /// is significantly higher than expected. /// + /// is significantly higher than expected. + /// public int? PayloadSizeThresholdInBytes { get; set; } = null; } } From 23b3f99a7f28c92472f670cd3fc4729129598345 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Wed, 24 Apr 2024 07:44:52 +0530 Subject: [PATCH 09/11] updated contract --- .../Contracts/DotNetSDKAPI.json | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json index 84ea3b8bb1..962d8e8f71 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json @@ -3686,29 +3686,29 @@ "Microsoft.Azure.Cosmos.CosmosThresholdOptions;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": { "Subclasses": {}, "Members": { - "Double get_RequestChargeThreshold()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "System.Nullable`1[System.Double] get_RequestChargeThreshold()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ "CompilerGeneratedAttribute" ], - "MethodInfo": "Double get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "System.Nullable`1[System.Double] get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "Double RequestChargeThreshold": { + "System.Nullable`1[System.Double] RequestChargeThreshold": { "Type": "Property", "Attributes": [], - "MethodInfo": "Double RequestChargeThreshold;CanRead:True;CanWrite:True;Double get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_RequestChargeThreshold(Double);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "System.Nullable`1[System.Double] RequestChargeThreshold;CanRead:True;CanWrite:True;System.Nullable`1[System.Double] get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_RequestChargeThreshold(System.Nullable`1[System.Double]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "Int32 get_PayloadSizeThresholdInBytes()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "System.Nullable`1[System.Int32] get_PayloadSizeThresholdInBytes()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ "CompilerGeneratedAttribute" ], - "MethodInfo": "Int32 get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "System.Nullable`1[System.Int32] get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "Int32 PayloadSizeThresholdInBytes": { + "System.Nullable`1[System.Int32] PayloadSizeThresholdInBytes": { "Type": "Property", "Attributes": [], - "MethodInfo": "Int32 PayloadSizeThresholdInBytes;CanRead:True;CanWrite:True;Int32 get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_PayloadSizeThresholdInBytes(Int32);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "System.Nullable`1[System.Int32] PayloadSizeThresholdInBytes;CanRead:True;CanWrite:True;System.Nullable`1[System.Int32] get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_PayloadSizeThresholdInBytes(System.Nullable`1[System.Int32]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, "System.TimeSpan get_NonPointOperationLatencyThreshold()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", @@ -3746,12 +3746,12 @@ ], "MethodInfo": "Void set_NonPointOperationLatencyThreshold(System.TimeSpan);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "Void set_PayloadSizeThresholdInBytes(Int32)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Void set_PayloadSizeThresholdInBytes(System.Nullable`1[System.Int32])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ "CompilerGeneratedAttribute" ], - "MethodInfo": "Void set_PayloadSizeThresholdInBytes(Int32);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "Void set_PayloadSizeThresholdInBytes(System.Nullable`1[System.Int32]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, "Void set_PointOperationLatencyThreshold(System.TimeSpan)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", @@ -3760,12 +3760,12 @@ ], "MethodInfo": "Void set_PointOperationLatencyThreshold(System.TimeSpan);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, - "Void set_RequestChargeThreshold(Double)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Void set_RequestChargeThreshold(System.Nullable`1[System.Double])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { "Type": "Method", "Attributes": [ "CompilerGeneratedAttribute" ], - "MethodInfo": "Void set_RequestChargeThreshold(Double);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + "MethodInfo": "Void set_RequestChargeThreshold(System.Nullable`1[System.Double]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" } }, "NestedTypes": {} From 19711857074b6a0bdd8a43b1c99ebd014cc12fbe Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Mon, 29 Apr 2024 23:15:14 +0530 Subject: [PATCH 10/11] changed event name --- .../OpenTelemetry/CosmosDbEventSource.cs | 36 +--- ...riterBaselineTests.BulkOperationsAsync.xml | 200 +++++++++--------- ...aceWriterBaselineTests.ChangeFeedAsync.xml | 42 ++-- ...eWriterBaselineTests.MiscellanousAsync.xml | 8 +- ...EndTraceWriterBaselineTests.QueryAsync.xml | 56 ++--- ...TraceWriterBaselineTests.ReadFeedAsync.xml | 32 +-- ...TraceWriterBaselineTests.ReadManyAsync.xml | 4 +- ...selineTests.StreamPointOperationsAsync.xml | 8 +- ...aselineTests.TypedPointOperationsAsync.xml | 8 +- 9 files changed, 188 insertions(+), 206 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs index e3bdfe709d..fe22d5ed11 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs @@ -46,21 +46,15 @@ public static void RecordDiagnosticsForRequests( else if (DiagnosticsFilterHelper.IsLatencyThresholdCrossed( config: config, operationType: operationType, - response: response)) + response: response) || + (config.RequestChargeThreshold is not null && + config.RequestChargeThreshold <= response.RequestCharge) || + (config.PayloadSizeThresholdInBytes is not null && + DiagnosticsFilterHelper.IsPayloadSizeThresholdCrossed( + config: config, + response: response))) { - CosmosDbEventSource.Singleton.LatencyOverThreshold(response.Diagnostics.ToString()); - } - else if (config.RequestChargeThreshold is not null && - config.RequestChargeThreshold <= response.RequestCharge) - { - CosmosDbEventSource.Singleton.RequestChargeOverThreshold(response.Diagnostics.ToString()); - } - else if (config.PayloadSizeThresholdInBytes is not null && - DiagnosticsFilterHelper.IsPayloadSizeThresholdCrossed( - config: config, - response: response)) - { - CosmosDbEventSource.Singleton.PayloadSizeOverThreshold(response.Diagnostics.ToString()); + CosmosDbEventSource.Singleton.ThresholdViolation(response.Diagnostics.ToString()); } } } @@ -81,7 +75,7 @@ private void Exception(string message) } [Event(2, Level = EventLevel.Warning)] - private void LatencyOverThreshold(string message) + private void ThresholdViolation(string message) { this.WriteEvent(2, message); } @@ -91,17 +85,5 @@ private void FailedRequest(string message) { this.WriteEvent(3, message); } - - [Event(4, Level = EventLevel.Warning)] - private void RequestChargeOverThreshold(string message) - { - this.WriteEvent(4, message); - } - - [Event(5, Level = EventLevel.Warning)] - private void PayloadSizeOverThreshold(string message) - { - this.WriteEvent(5, message); - } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml index af8d3b4cf7..69e7a3c52f 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml @@ -343,16 +343,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -680,16 +680,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -1017,16 +1017,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -1354,16 +1354,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -1691,16 +1691,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -2028,16 +2028,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -2365,16 +2365,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -2702,16 +2702,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -3039,16 +3039,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + @@ -3376,16 +3376,16 @@ Some Value Some Value - - - - - - - - - - + + + + + + + + + + diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ChangeFeedAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ChangeFeedAsync.xml index 9d6cb5c5a9..45781f33c4 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ChangeFeedAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ChangeFeedAsync.xml @@ -1118,11 +1118,11 @@ Some Value South Central US - - - - - + + + + + @@ -1864,11 +1864,11 @@ Some Value South Central US - - - - - + + + + + @@ -2591,11 +2591,11 @@ Some Value South Central US - - - - - + + + + + @@ -3338,11 +3338,11 @@ Some Value South Central US - - - - - + + + + + @@ -3662,7 +3662,7 @@ Some Value South Central US - + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.MiscellanousAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.MiscellanousAsync.xml index 533473c213..b445a3d8c7 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.MiscellanousAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.MiscellanousAsync.xml @@ -151,8 +151,8 @@ Some Value Some Value - - + + @@ -292,8 +292,8 @@ Some Value Some Value - - + + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml index 12e27e0576..82ad44b108 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.QueryAsync.xml @@ -694,10 +694,10 @@ Some Value South Central US - - - - + + + + @@ -1415,10 +1415,10 @@ Some Value South Central US - - - - + + + + @@ -2117,10 +2117,10 @@ Some Value South Central US - - - - + + + + @@ -2839,10 +2839,10 @@ Some Value South Central US - - - - + + + + @@ -3635,10 +3635,10 @@ Some Value South Central US - - - - + + + + @@ -4346,10 +4346,10 @@ Some Value South Central US - - - - + + + + @@ -5077,10 +5077,10 @@ Some Value South Central US - - - - + + + + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadFeedAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadFeedAsync.xml index b6ce2e777d..2282980891 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadFeedAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadFeedAsync.xml @@ -656,10 +656,10 @@ Some Value South Central US - - - - + + + + @@ -1339,10 +1339,10 @@ Some Value South Central US - - - - + + + + @@ -2003,10 +2003,10 @@ Some Value South Central US - - - - + + + + @@ -2687,10 +2687,10 @@ Some Value South Central US - - - - + + + + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml index cf7a291db0..d008ef7dbe 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.ReadManyAsync.xml @@ -569,7 +569,7 @@ Some Value South Central US - + @@ -1154,7 +1154,7 @@ Some Value South Central US - + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.StreamPointOperationsAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.StreamPointOperationsAsync.xml index d49a6731e7..bb444ff589 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.StreamPointOperationsAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.StreamPointOperationsAsync.xml @@ -118,7 +118,7 @@ Some Value South Central US - + @@ -234,7 +234,7 @@ Some Value South Central US - + @@ -358,7 +358,7 @@ Some Value South Central US - + @@ -477,7 +477,7 @@ Some Value South Central US - + \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.TypedPointOperationsAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.TypedPointOperationsAsync.xml index 8cd5278ea1..30629674f6 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.TypedPointOperationsAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.TypedPointOperationsAsync.xml @@ -138,7 +138,7 @@ Some Value South Central US - + @@ -259,7 +259,7 @@ Some Value South Central US - + @@ -393,7 +393,7 @@ Some Value South Central US - + @@ -516,7 +516,7 @@ Some Value South Central US - + \ No newline at end of file From 46e49b00b11b02e430752a0c3fff5c86245f4f7f Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Mon, 29 Apr 2024 23:25:01 +0530 Subject: [PATCH 11/11] remove unused import --- .../src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs index fe22d5ed11..fbcae597c9 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Telemetry { - using System; using System.Diagnostics.Tracing; using global::Azure.Core.Diagnostics; using Microsoft.Azure.Cosmos.Telemetry.Diagnostics; @@ -16,7 +15,7 @@ namespace Microsoft.Azure.Cosmos.Telemetry internal sealed class CosmosDbEventSource : AzureEventSource { internal const string EventSourceName = "Azure-Cosmos-Operation-Request-Diagnostics"; - + private static CosmosDbEventSource Singleton { get; } = new CosmosDbEventSource(); private CosmosDbEventSource() @@ -44,9 +43,9 @@ public static void RecordDiagnosticsForRequests( CosmosDbEventSource.Singleton.FailedRequest(response.Diagnostics.ToString()); } else if (DiagnosticsFilterHelper.IsLatencyThresholdCrossed( - config: config, - operationType: operationType, - response: response) || + config: config, + operationType: operationType, + response: response) || (config.RequestChargeThreshold is not null && config.RequestChargeThreshold <= response.RequestCharge) || (config.PayloadSizeThresholdInBytes is not null &&