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 b4f59d25f0..3eb768f71b 100644
--- a/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs
+++ b/Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs
@@ -7,20 +7,48 @@ namespace Microsoft.Azure.Cosmos
using System;
///
- /// Threshold values for Distributed Tracing
+ /// 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
{
///
- /// 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 than expected.
+ ///
+ 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.
+ ///
+ 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 f7fe0c307f..fbcae597c9 100644
--- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs
+++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs
@@ -15,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()
@@ -35,17 +35,26 @@ public static void RecordDiagnosticsForRequests(
Documents.OperationType operationType,
OpenTelemetryAttributes response)
{
- if (!DiagnosticsFilterHelper.IsSuccessfulResponse(
- response.StatusCode, response.SubStatusCode) && CosmosDbEventSource.IsEnabled(EventLevel.Warning))
- {
- CosmosDbEventSource.Singleton.FailedRequest(response.Diagnostics.ToString());
- }
- else if (DiagnosticsFilterHelper.IsLatencyThresholdCrossed(
- config: config,
- operationType: operationType,
- response: response) && CosmosDbEventSource.IsEnabled(EventLevel.Warning))
+ if (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) ||
+ (config.RequestChargeThreshold is not null &&
+ config.RequestChargeThreshold <= response.RequestCharge) ||
+ (config.PayloadSizeThresholdInBytes is not null &&
+ DiagnosticsFilterHelper.IsPayloadSizeThresholdCrossed(
+ config: config,
+ response: response)))
+ {
+ CosmosDbEventSource.Singleton.ThresholdViolation(response.Diagnostics.ToString());
+ }
}
}
@@ -65,7 +74,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);
}
diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs
index 3c0646f101..0d0c7019f1 100644
--- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs
+++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs
@@ -21,28 +21,59 @@ public static bool IsLatencyThresholdCrossed(
OperationType operationType,
OpenTelemetryAttributes response)
{
- return response.Diagnostics.GetClientElapsedTime() > DiagnosticsFilterHelper.DefaultThreshold(operationType, config);
+ 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
///
/// 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.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
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..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,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": {
+ "System.Nullable`1[System.Double] get_RequestChargeThreshold()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
+ "Type": "Method",
+ "Attributes": [
+ "CompilerGeneratedAttribute"
+ ],
+ "MethodInfo": "System.Nullable`1[System.Double] get_RequestChargeThreshold();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
+ },
+ "System.Nullable`1[System.Double] RequestChargeThreshold": {
+ "Type": "Property",
+ "Attributes": [],
+ "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;"
+ },
+ "System.Nullable`1[System.Int32] get_PayloadSizeThresholdInBytes()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
+ "Type": "Method",
+ "Attributes": [
+ "CompilerGeneratedAttribute"
+ ],
+ "MethodInfo": "System.Nullable`1[System.Int32] get_PayloadSizeThresholdInBytes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
+ },
+ "System.Nullable`1[System.Int32] PayloadSizeThresholdInBytes": {
+ "Type": "Property",
+ "Attributes": [],
+ "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",
"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(System.Nullable`1[System.Int32])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
+ "Type": "Method",
+ "Attributes": [
+ "CompilerGeneratedAttribute"
+ ],
+ "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",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_PointOperationLatencyThreshold(System.TimeSpan);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
+ },
+ "Void set_RequestChargeThreshold(System.Nullable`1[System.Double])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
+ "Type": "Method",
+ "Attributes": [
+ "CompilerGeneratedAttribute"
+ ],
+ "MethodInfo": "Void set_RequestChargeThreshold(System.Nullable`1[System.Double]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
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..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()
{
@@ -79,7 +110,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);