pub struct SloTracker { /* private fields */ }Expand description
SLO tracker for workspace index operations.
Tracks latency and success/failure for all operation types, providing SLO compliance monitoring and reporting.
Implementations§
Source§impl SloTracker
impl SloTracker
Sourcepub fn new(config: SloConfig) -> SloTracker
pub fn new(config: SloConfig) -> SloTracker
Sourcepub fn start_operation(&self, _operation_type: OperationType) -> Instant
pub fn start_operation(&self, _operation_type: OperationType) -> Instant
Start tracking an operation.
Returns an Instant to pass to Self::record_operation_type.
The operation_type parameter is accepted for call-site readability
but is not encoded in the returned timestamp — always pair with
record_operation_type using the same type.
§Examples
use perl_workspace::slo::{OperationResult, OperationType, SloTracker};
let tracker = SloTracker::default();
let start = tracker.start_operation(OperationType::DefinitionLookup);
// ... perform operation ...
tracker.record_operation_type(OperationType::DefinitionLookup, start, OperationResult::Success);Sourcepub fn record_operation(&self, start: Instant, result: OperationResult)
👎Deprecated since 0.13.0: records to every operation-type tracker at once — use record_operation_type instead
pub fn record_operation(&self, start: Instant, result: OperationResult)
records to every operation-type tracker at once — use record_operation_type instead
Record the completion of an operation.
§Deprecation
This method records the duration to every operation-type tracker
simultaneously, which pollutes all per-type statistics. Use
Self::record_operation_type instead to target the correct tracker.
§Examples
use perl_workspace::slo::{SloTracker, OperationType, OperationResult};
let tracker = SloTracker::default();
let start = tracker.start_operation(OperationType::DefinitionLookup);
// ... perform operation ...
// Prefer: tracker.record_operation_type(OperationType::DefinitionLookup, start, OperationResult::Success);
#[allow(deprecated)]
tracker.record_operation(start, OperationResult::Success);Sourcepub fn record_operation_type(
&self,
operation_type: OperationType,
start: Instant,
result: OperationResult,
)
pub fn record_operation_type( &self, operation_type: OperationType, start: Instant, result: OperationResult, )
Record the completion of a specific operation type.
§Arguments
operation_type- Type of operationstart- Timestamp returned fromstart_operationresult- Operation result
§Examples
use perl_workspace::slo::{SloTracker, OperationType, OperationResult};
let tracker = SloTracker::default();
let start = tracker.start_operation(OperationType::DefinitionLookup);
// ... perform operation ...
tracker.record_operation_type(OperationType::DefinitionLookup, start, OperationResult::Success);Sourcepub fn statistics(&self, operation_type: OperationType) -> SloStatistics
pub fn statistics(&self, operation_type: OperationType) -> SloStatistics
Get SLO statistics for a specific operation type.
§Arguments
operation_type- Type of operation
§Returns
SLO statistics for the operation type.
§Examples
use perl_workspace::slo::{SloTracker, OperationType};
let tracker = SloTracker::default();
let stats = tracker.statistics(OperationType::DefinitionLookup);Sourcepub fn all_statistics(&self) -> HashMap<OperationType, SloStatistics>
pub fn all_statistics(&self) -> HashMap<OperationType, SloStatistics>
Sourcepub fn all_slos_met(&self) -> bool
pub fn all_slos_met(&self) -> bool
Sourcepub fn sample_count(&self, operation_type: OperationType) -> usize
pub fn sample_count(&self, operation_type: OperationType) -> usize
Return the number of samples currently in the window for operation_type.
Useful for testing and monitoring — confirms that samples are being recorded without computing full percentile statistics.
§Examples
use perl_workspace::slo::{OperationResult, OperationType, SloTracker};
let tracker = SloTracker::default();
assert_eq!(tracker.sample_count(OperationType::DefinitionLookup), 0);
let start = tracker.start_operation(OperationType::DefinitionLookup);
tracker.record_operation_type(OperationType::DefinitionLookup, start, OperationResult::Success);
assert_eq!(tracker.sample_count(OperationType::DefinitionLookup), 1);