Skip to content

Commit

Permalink
add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Apr 24, 2024
1 parent dc98416 commit a978141
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 3 additions & 7 deletions Microsoft.Azure.Cosmos/src/CosmosThresholdOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// </summary>
/// <value>1000 RU</value>
public double RequestChargeThreshold { get; set; } = 1000;
public double? RequestChargeThreshold { get; set; } = null;

/// <summary>
/// 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
/// </summary>
/// <value>2147483647 Bytes</value>
public int PayloadSizeThresholdInBytes { get; set; } = Int32.MaxValue;
/// is significantly higher than expected. /// </summary>
public int? PayloadSizeThresholdInBytes { get; set; } = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ public static bool IsEnabled(EventLevel level)
{
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))
{
Expand Down

0 comments on commit a978141

Please sign in to comment.