WEB Carrier Counters + Status

Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
Alexey
2026-08-31 21:39:09 +03:00
parent 66f2b8889f
commit 718ce0847e
51 changed files with 2252 additions and 453 deletions
+59
View File
@@ -0,0 +1,59 @@
use super::*;
use crate::config::WebCarrier;
use crate::web::manager::CarrierFailure;
#[test]
fn fixed_counter_sets_and_acceptor_guard_are_exact() {
let telemetry = WebTelemetry::new();
let guard = telemetry.acceptor_guard();
assert_eq!(telemetry.live_acceptors(), 1);
telemetry.record_rejection(WebRejectionReason::HttpConnectionCapacity);
telemetry.record_overload(WebHttpConnectionOverloadOutcome::Dropped);
telemetry.record_decoy(WebDecoyUpstreamOutcome::ConnectRefused);
telemetry.record_carrier_selection(
WebCarrier::Https,
WebCarrierSelectionDisposition::Cold,
);
telemetry.record_carrier_failure(
WebCarrier::Https,
WebCarrierFailurePhase::Provisional,
CarrierFailure::Network,
);
telemetry.record_carrier_learning(
WebCarrier::Https,
WebCarrierLearningOutcome::Recorded,
);
assert_eq!(telemetry.rejection_counters().len(), WebRejectionReason::ALL.len());
assert_eq!(
telemetry.overload_counters().len(),
WebHttpConnectionOverloadOutcome::ALL.len()
);
assert_eq!(
telemetry.decoy_counters().len(),
WebDecoyUpstreamOutcome::ALL.len()
);
assert_eq!(
telemetry.carrier_selection_counters().len(),
WebCarrier::ALL.len() * WebCarrierSelectionDisposition::ALL.len()
);
assert_eq!(
telemetry.carrier_failure_counters().len(),
WebCarrier::ALL.len()
* WebCarrierFailurePhase::ALL.len()
* CarrierFailure::ALL.len()
);
assert_eq!(
telemetry.carrier_learning_counters().len(),
WebCarrier::ALL.len() * WebCarrierLearningOutcome::ALL.len()
);
assert_eq!(
telemetry.rejection_total(WebRejectionReason::HttpConnectionCapacity),
1
);
assert_eq!(
telemetry.last_decoy().map(|value| value.0),
Some("connect_refused")
);
drop(guard);
assert_eq!(telemetry.live_acceptors(), 0);
}