共用方式為


CosmosDiagnosticsThresholds Class

  • java.lang.Object
    • com.azure.cosmos.CosmosDiagnosticsThresholds

public final class CosmosDiagnosticsThresholds

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.

Field Summary

Modifier and Type Field and Description
static final Duration DEFAULT_NON_POINT_OPERATION_LATENCY_THRESHOLD

The default latency threshold to determine whether to include request diagnostics or not for non-point operations

static final int DEFAULT_PAYLOAD_SIZE_THRESHOLD_IN_BYTES

The default payload size (in bytes) threshold to determine whether to include request diagnostics or not

static final Duration DEFAULT_POINT_OPERATION_LATENCY_THRESHOLD

The default latency threshold to determine whether to include request diagnostics or not for point operations

static final float DEFAULT_REQUEST_CHARGE_THRESHOLD

The default request charge (RU) threshold to determine whether to include request diagnostics or not

Constructor Summary

Constructor Description
CosmosDiagnosticsThresholds()

Creates an instance of the CosmosDiagnosticsThresholds class with default values

Method Summary

Modifier and Type Method and Description
CosmosDiagnosticsThresholds setFailureHandler(BiPredicate<Integer,Integer> failureHandler)

Can be used to customize the logic determining whether the outcome of an operation (based on statusCode + subStatusCode) is considered a failure (and diagnostics will be emitted) or not.

CosmosDiagnosticsThresholds setNonPointOperationLatencyThreshold(Duration nonPointOperationLatencyThreshold)

Can be used to define custom latency thresholds.

CosmosDiagnosticsThresholds setPayloadSizeThreshold(int bytes)

Can be used to define a payload size threshold.

CosmosDiagnosticsThresholds setPointOperationLatencyThreshold(Duration pointOperationLatencyThreshold)

Can be used to define custom latency thresholds.

CosmosDiagnosticsThresholds setRequestChargeThreshold(float requestChargeThreshold)

Can be used to define a custom RU (request charge) threshold.

String toString()

Methods inherited from java.lang.Object

Field Details

DEFAULT_NON_POINT_OPERATION_LATENCY_THRESHOLD

public static final Duration DEFAULT_NON_POINT_OPERATION_LATENCY_THRESHOLD

The default latency threshold to determine whether to include request diagnostics or not for non-point operations

DEFAULT_PAYLOAD_SIZE_THRESHOLD_IN_BYTES

public static final int DEFAULT_PAYLOAD_SIZE_THRESHOLD_IN_BYTES

The default payload size (in bytes) threshold to determine whether to include request diagnostics or not

DEFAULT_POINT_OPERATION_LATENCY_THRESHOLD

public static final Duration DEFAULT_POINT_OPERATION_LATENCY_THRESHOLD

The default latency threshold to determine whether to include request diagnostics or not for point operations

DEFAULT_REQUEST_CHARGE_THRESHOLD

public static final float DEFAULT_REQUEST_CHARGE_THRESHOLD

The default request charge (RU) threshold to determine whether to include request diagnostics or not

Constructor Details

CosmosDiagnosticsThresholds

public CosmosDiagnosticsThresholds()

Creates an instance of the CosmosDiagnosticsThresholds class with default values

Method Details

setFailureHandler

public CosmosDiagnosticsThresholds setFailureHandler(BiPredicate failureHandler)

Can be used to customize the logic determining whether the outcome of an operation (based on statusCode + subStatusCode) is considered a failure (and diagnostics will be emitted) or not. By default, all status codes >= 400 except for (404/0 - item not found, 409/0 - conflict, document with same id+pk already exists, 412/0 - (etag) pre-condition failure and 429/3200 - throttling due to provisioned RU exceeded) are considered failures. Those exceptions can happen very frequently and are usually expected under certain circumstances by applications - so, the noise-level for emitting diagnostics would be too high. The first parameter will be the status code - the second parameter the subStatusCode. The returned boolean of the function would indicate whether the operation should be considered as failure form a diagnostics perspective.

Parameters:

failureHandler - the function that will be used to determine whether a status code/sub-status code tuple should be considered a failure.

Returns:

current CosmosDiagnosticsThresholds instance

setNonPointOperationLatencyThreshold

public CosmosDiagnosticsThresholds setNonPointOperationLatencyThreshold(Duration nonPointOperationLatencyThreshold)

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 DEFAULT_POINT_OPERATION_LATENCY_THRESHOLD, for non-point operations DEFAULT_NON_POINT_OPERATION_LATENCY_THRESHOLD.

Parameters:

nonPointOperationLatencyThreshold - the latency threshold for all operations except (ReadItem, CreateItem, UpsertItem, ReplaceItem, PatchItem or DeleteItem)

Returns:

current CosmosDiagnosticsThresholds instance

setPayloadSizeThreshold

public CosmosDiagnosticsThresholds setPayloadSizeThreshold(int bytes)

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 are DEFAULT_PAYLOAD_SIZE_THRESHOLD_IN_BYTES bytes.

Parameters:

bytes - the threshold for the payload size in bytes

Returns:

current CosmosDiagnosticsThresholds instance

setPointOperationLatencyThreshold

public CosmosDiagnosticsThresholds setPointOperationLatencyThreshold(Duration pointOperationLatencyThreshold)

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 DEFAULT_POINT_OPERATION_LATENCY_THRESHOLD, for non-point operations DEFAULT_NON_POINT_OPERATION_LATENCY_THRESHOLD.

Parameters:

pointOperationLatencyThreshold - the latency threshold for point operations (ReadItem, CreateItem, UpsertItem, ReplaceItem, PatchItem or DeleteItem)

Returns:

current CosmosDiagnosticsThresholds instance

setRequestChargeThreshold

public CosmosDiagnosticsThresholds setRequestChargeThreshold(float requestChargeThreshold)

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 are DEFAULT_REQUEST_CHARGE_THRESHOLD RUs.

Parameters:

requestChargeThreshold - The total request charge threshold for an operation. When this threshold is exceeded for an operation the corresponding detailed diagnostics will be emitted.

Returns:

current CosmosDiagnosticsThresholds instance

toString

public String toString()

Overrides:

CosmosDiagnosticsThresholds.toString()

Applies to