Package com.azure.cosmos
Class CosmosDiagnosticsContext
java.lang.Object
com.azure.cosmos.CosmosDiagnosticsContext
This class provides metadata for an operation in the Cosmos DB SDK that can be used
by diagnostic handlers
-
Method Summary
Modifier and TypeMethodDescriptionThe name of the account related to the operationThe actual number of items returned by a feed operationReturns the connection mode used in the client.Returns the set of contacted regionsThe name of the container related to the operationThe name of the database related to the operationThe diagnostic records for service interactions within the scope of this SDK operationThe total end-to-end duration of the operation.The effective consistency level of the operationThe final error when the operation failedGets the custom ids.The max. number of items requested in a feed operationint
The max. request payload size in bytesint
The max. response payload size in bytes.The operation identifier of the operation - this can be used to add a dimension for feed operations - like queries - so, metrics and diagnostics can be separated for different query types etc.The operation type of the operationThe query statement send by clientGets a collection ofCosmosDiagnosticsRequestInfo
records providing more information about individual requests issued in the transport layer to process this operation.The resource type of the operationint
Returns the number of retries and/or attempts for speculative processing.int
The final status code of the operation (possibly after retries)int
The final sub-status code of the operation (possibly after retries)Returns the system usage NOTE: this information is not included in the json representation returned fromtoJson()
because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included.float
The total request charge across all retries.The trackingId of a write operation.Gets the UserAgent header value used by the client issuing this operation NOTE: this information is not included in the json representation returned fromtoJson()
because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included.boolean
Returns a flag indicating whether the operation has been completed yet.boolean
A flag indicating whether the operation should be considered failed or not based on the status code handling rules inCosmosDiagnosticsThresholds.setFailureHandler(java.util.function.BiPredicate)
boolean
A flag indicating whether the operation is a point operation or not.boolean
Indicates whether the latency, request charge or payload size of the operation exceeded the given thresholdtoJson()
Returns a json-string representation of the diagnostics context.
-
Method Details
-
getAccountName
The name of the account related to the operation- Returns:
- the name of the account related to the operation
-
getDatabaseName
The name of the database related to the operation- Returns:
- the name of the database related to the operation
-
getContainerName
The name of the container related to the operation- Returns:
- the name of the collection related to the operation
-
getResourceType
The resource type of the operation- Returns:
- the resource type of the operation
-
getOperationType
The operation type of the operation- Returns:
- the operation type of the operation
-
getTrackingId
The trackingId of a write operation. Will be null for read-/query- or feed operations or when non-idempotent writes are disabled for writes or only enabled without trackingId propagation.- Returns:
- the trackingId of an operation
-
isPointOperation
public boolean isPointOperation()A flag indicating whether the operation is a point operation or not.- Returns:
- a flag indicating whether the operation is a point operation or not.
-
getOperationId
The operation identifier of the operation - this can be used to add a dimension for feed operations - like queries - so, metrics and diagnostics can be separated for different query types etc.- Returns:
- the operation identifier of the operation
-
getEffectiveConsistencyLevel
The effective consistency level of the operation- Returns:
- the effective consistency level of the operation
-
getMaxItemCount
The max. number of items requested in a feed operation- Returns:
- the max. number of items requested in a feed operation. Will be null for point operations.
-
getActualItemCount
The actual number of items returned by a feed operation- Returns:
- the actual number of items returned by a feed operation. Will be null for point operations.
-
getQueryStatement
The query statement send by client- Returns:
- the query statement
-
isThresholdViolated
public boolean isThresholdViolated()Indicates whether the latency, request charge or payload size of the operation exceeded the given threshold- Returns:
- a flag indicating whether the latency, request charge or payload size of the operation exceeded its threshold.
-
getStatusCode
public int getStatusCode()The final status code of the operation (possibly after retries)- Returns:
- the final status code of the operation (possibly after retries)
-
getSubStatusCode
public int getSubStatusCode()The final sub-status code of the operation (possibly after retries)- Returns:
- the final sub-status code of the operation (possibly after retries)
-
getFinalError
The final error when the operation failed- Returns:
- the final error when the operation failed
-
getMaxRequestPayloadSizeInBytes
public int getMaxRequestPayloadSizeInBytes()The max. request payload size in bytes- Returns:
- the max. request payload size in bytes
-
getMaxResponsePayloadSizeInBytes
public int getMaxResponsePayloadSizeInBytes()The max. response payload size in bytes.- Returns:
- the max. response payload size in bytes
-
getTotalRequestCharge
public float getTotalRequestCharge()The total request charge across all retries.- Returns:
- the total request charge across all retries.
-
getContactedRegionNames
Returns the set of contacted regions- Returns:
- the set of contacted regions
-
getSystemUsage
Returns the system usage NOTE: this information is not included in the json representation returned fromtoJson()
because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included. Calling this method will lazily collect the system usage - which can be useful when writing a customCosmosDiagnosticsHandler
- Returns:
- the system usage
-
getRetryCount
public int getRetryCount()Returns the number of retries and/or attempts for speculative processing.- Returns:
- the number of retries and/or attempts for speculative processing.
-
getDiagnostics
The diagnostic records for service interactions within the scope of this SDK operation- Returns:
- the diagnostic records for service interactions within the scope of this SDK operation
-
isCompleted
public boolean isCompleted()Returns a flag indicating whether the operation has been completed yet.- Returns:
- a flag indicating whether the operation has been completed yet.
-
getDuration
The total end-to-end duration of the operation.- Returns:
- the total end-to-end duration of the operation.
-
isFailure
public boolean isFailure()A flag indicating whether the operation should be considered failed or not based on the status code handling rules inCosmosDiagnosticsThresholds.setFailureHandler(java.util.function.BiPredicate)
- Returns:
- a flag indicating whether the operation should be considered failed or not
-
toJson
Returns a json-string representation of the diagnostics context. This string uses json format for readability, but it should be treated as an opaque string - the format can and will change between SDK versions - for any automatic processing of the diagnostics information the get-properties of public API should be used.- Returns:
- a json-string representation of the diagnostics context. This string uses json format for readability, but it should be treated as an opaque string - the format can and will change between SDK versions - for any automatic processing of the diagnostics information the get-properties of public API should be used.
-
getUserAgent
Gets the UserAgent header value used by the client issuing this operation NOTE: this information is not included in the json representation returned fromtoJson()
because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included.- Returns:
- the UserAgent header value used for the client that issued this operation
-
getConnectionMode
Returns the connection mode used in the client. NOTE: this information is not included in the json representation returned fromtoJson()
because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included.- Returns:
- the connection mode used in the client.
-
getRequestInfo
Gets a collection ofCosmosDiagnosticsRequestInfo
records providing more information about individual requests issued in the transport layer to process this operation. NOTE: this information is not included in the json representation returned fromtoJson()
because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included. Calling this method will lazily collect the user agent - which can be useful when writing a customCosmosDiagnosticsHandler
- Returns:
- a collection of
CosmosDiagnosticsRequestInfo
records providing more information about individual requests issued in the transport layer to process this operation.
-
getKeywordIdentifiers
Gets the custom ids.- Returns:
- the custom ids.
-