pub struct TransactionMetrics {
pub metrics: Arc<Mutex<MetricsReport>>,
}
Expand description
Tracks metrics for a transaction.
This struct maintains transaction metrics protected by a mutex to allow safe concurrent access.
Fields§
§metrics: Arc<Mutex<MetricsReport>>
All metrics for the transaction, organized by category
Implementations§
Source§impl TransactionMetrics
impl TransactionMetrics
Sourcepub fn set_read_version(&self, version: i64)
pub fn set_read_version(&self, version: i64)
Sourcepub fn set_commit_version(&self, version: i64)
pub fn set_commit_version(&self, version: i64)
Sourcepub fn reset_current(&self)
pub fn reset_current(&self)
Resets the current metrics and increments the retry counter in total metrics.
This method is called when a transaction is retried due to a conflict or other retryable error. It increments the retry count in the transaction info and resets the current metrics to zero. It also merges current custom metrics into total custom metrics before clearing them.
Sourcepub fn increment_retries(&self)
pub fn increment_retries(&self)
Increment the retry counter
Sourcepub fn report_metrics(&self, fdb_command: FdbCommand)
pub fn report_metrics(&self, fdb_command: FdbCommand)
Reports metrics for a specific FDB command by incrementing the appropriate counters.
This method updates both the current and total metrics for the given command.
§Arguments
fdb_command
- The FDB command to report metrics for
Sourcepub fn get_retries(&self) -> u64
pub fn get_retries(&self) -> u64
Sourcepub fn get_metrics_data(&self) -> MetricsReport
pub fn get_metrics_data(&self) -> MetricsReport
Sourcepub fn get_transaction_info(&self) -> TransactionInfo
pub fn get_transaction_info(&self) -> TransactionInfo
Returns a clone of the transaction information.
§Returns
TransactionInfo
- A clone of the transaction information
Sourcepub fn set_custom(&self, name: &str, value: u64, labels: &[(&str, &str)])
pub fn set_custom(&self, name: &str, value: u64, labels: &[(&str, &str)])
Set a custom metric
§Arguments
name
- The name of the metricvalue
- The value to setlabels
- Key-value pairs for labeling the metric
Sourcepub fn increment_custom(&self, name: &str, amount: u64, labels: &[(&str, &str)])
pub fn increment_custom(&self, name: &str, amount: u64, labels: &[(&str, &str)])
Increment a custom metric
§Arguments
name
- The name of the metricamount
- The amount to increment bylabels
- Key-value pairs for labeling the metric
Sourcepub fn record_commit_time(&self, duration_ms: u64)
pub fn record_commit_time(&self, duration_ms: u64)
Record commit execution time
§Arguments
duration_ms
- The duration of the commit execution in milliseconds
Sourcepub fn add_error_time(&self, duration_ms: u64)
pub fn add_error_time(&self, duration_ms: u64)
Add an error execution time to the list
§Arguments
duration_ms
- The duration of the error handling in milliseconds
Sourcepub fn set_execution_time(&self, duration_ms: u64)
pub fn set_execution_time(&self, duration_ms: u64)
Set the total execution time
§Arguments
duration_ms
- The total duration of the transaction in milliseconds
Sourcepub fn get_total_error_time(&self) -> u64
pub fn get_total_error_time(&self) -> u64
Get the sum of all error handling times
§Returns
u64
- The total time spent handling errors in milliseconds
Trait Implementations§
Source§impl Clone for TransactionMetrics
impl Clone for TransactionMetrics
Source§fn clone(&self) -> TransactionMetrics
fn clone(&self) -> TransactionMetrics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more