CosmosDiagnosticsContext Class
- java.
lang. Object - com.
azure. cosmos. CosmosDiagnosticsContext
- com.
public final class CosmosDiagnosticsContext
This class provides metadata for an operation in the Cosmos DB SDK that can be used by diagnostic handlers
Method Summary
Modifier and Type | Method and Description |
---|---|
String |
getAccountName()
The name of the account related to the operation |
Integer |
getActualItemCount()
The actual number of items returned by a feed operation |
String |
getConnectionMode()
Returns the connection mode used in the client. |
Set<String> |
getContactedRegionNames()
Returns the set of contacted regions |
String |
getContainerName()
The name of the container related to the operation |
String |
getDatabaseName()
The name of the database related to the operation |
Collection<Cosmos |
getDiagnostics()
The diagnostic records for service interactions within the scope of this SDK operation |
Duration |
getDuration()
The total end-to-end duration of the operation. |
Consistency |
getEffectiveConsistencyLevel()
The effective consistency level of the operation |
Throwable |
getFinalError()
The final error when the operation failed |
Set<String> |
getKeywordIdentifiers()
Gets the custom ids. |
Integer |
getMaxItemCount()
The max. |
int |
getMaxRequestPayloadSizeInBytes()
The max. |
int |
getMaxResponsePayloadSizeInBytes()
The max. |
String |
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. |
String |
getOperationType()
The operation type of the operation |
String |
getQueryStatement()
The query statement send by client |
Collection<Cosmos |
getRequestInfo()
Gets a collection of CosmosDiagnosticsRequestInfo records providing more information about individual requests issued in the transport layer to process this operation. |
String |
getResourceType()
The resource type of the operation |
int |
getRetryCount()
Returns the number of retries and/or attempts for speculative processing. |
int |
getStatusCode()
The final status code of the operation (possibly after retries) |
int |
getSubStatusCode()
The final sub-status code of the operation (possibly after retries) |
Map<String,Object> |
getSystemUsage()
Returns the system usage NOTE: this information is not included in the json representation returned from toJson() because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included. |
float |
getTotalRequestCharge()
The total request charge across all retries. |
String |
getTrackingId()
The tracking |
String |
getUserAgent()
Gets the User |
boolean |
isCompleted()
Returns a flag indicating whether the operation has been completed yet. |
boolean |
isFailure()
A flag indicating whether the operation should be considered failed or not based on the status code handling rules in CosmosDiagnosticsThresholds#setFailureHandler(java.util.function.BiPredicate) |
boolean |
isPointOperation()
A flag indicating whether the operation is a point operation or not. |
boolean |
isThresholdViolated()
Indicates whether the latency, request charge or payload size of the operation exceeded the given threshold |
String |
toJson()
Returns a json-string representation of the diagnostics context. |
Methods inherited from java.lang.Object
Method Details
getAccountName
public String getAccountName()
The name of the account related to the operation
Returns:
getActualItemCount
public Integer getActualItemCount()
The actual number of items returned by a feed operation
Returns:
getConnectionMode
public String getConnectionMode()
Returns the connection mode used in the client. NOTE: this information is not included in the json representation returned from toJson() because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included.
Returns:
getContactedRegionNames
public Set
Returns the set of contacted regions
Returns:
getContainerName
public String getContainerName()
The name of the container related to the operation
Returns:
getDatabaseName
public String getDatabaseName()
The name of the database related to the operation
Returns:
getDiagnostics
public Collection
The diagnostic records for service interactions within the scope of this SDK operation
Returns:
getDuration
public Duration getDuration()
The total end-to-end duration of the operation.
Returns:
getEffectiveConsistencyLevel
public ConsistencyLevel getEffectiveConsistencyLevel()
The effective consistency level of the operation
Returns:
getFinalError
public Throwable getFinalError()
The final error when the operation failed
Returns:
getKeywordIdentifiers
public Set
Gets the custom ids.
Returns:
getMaxItemCount
public Integer getMaxItemCount()
The max. number of items requested in a feed operation
Returns:
getMaxRequestPayloadSizeInBytes
public int getMaxRequestPayloadSizeInBytes()
The max. request payload size in bytes
Returns:
getMaxResponsePayloadSizeInBytes
public int getMaxResponsePayloadSizeInBytes()
The max. response payload size in bytes.
Returns:
getOperationId
public String 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:
getOperationType
public String getOperationType()
The operation type of the operation
Returns:
getQueryStatement
public String getQueryStatement()
The query statement send by client
Returns:
getRequestInfo
public Collection
Gets a collection of CosmosDiagnosticsRequestInfo 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 from toJson() 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 custom CosmosDiagnosticsHandler
Returns:
getResourceType
public String getResourceType()
The resource type of the operation
Returns:
getRetryCount
public int getRetryCount()
Returns the number of retries and/or attempts for speculative processing.
Returns:
getStatusCode
public int getStatusCode()
The final status code of the operation (possibly after retries)
Returns:
getSubStatusCode
public int getSubStatusCode()
The final sub-status code of the operation (possibly after retries)
Returns:
getSystemUsage
public Map
Returns the system usage NOTE: this information is not included in the json representation returned from toJson() 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 custom CosmosDiagnosticsHandler
Returns:
getTotalRequestCharge
public float getTotalRequestCharge()
The total request charge across all retries.
Returns:
getTrackingId
public String 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:
getUserAgent
public String getUserAgent()
Gets the UserAgent header value used by the client issuing this operation NOTE: this information is not included in the json representation returned from toJson() because it is usually only relevant when thresholds are violated, in which case the entire diagnostics json-string is included.
Returns:
isCompleted
public boolean isCompleted()
Returns a flag indicating whether the operation has been completed yet.
Returns:
isFailure
public boolean isFailure()
A flag indicating whether the operation should be considered failed or not based on the status code handling rules in CosmosDiagnosticsThresholds#setFailureHandler(java.util.function.BiPredicate)
Returns:
isPointOperation
public boolean isPointOperation()
A flag indicating whether the operation is a point operation or not.
Returns:
isThresholdViolated
public boolean isThresholdViolated()
Indicates whether the latency, request charge or payload size of the operation exceeded the given threshold
Returns:
toJson
public String 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:
Applies to
Azure SDK for Java