pub struct GatewayMetrics {Show 39 fields
pub start_time: Instant,
pub total_connections: AtomicU64,
pub total_disconnections: AtomicU64,
pub rejected_connections: AtomicU64,
pub total_requests: AtomicU64,
pub total_request_errors: AtomicU64,
pub total_response_bytes: AtomicU64,
pub backend_reconnects: AtomicU64,
pub backend_reconnect_failures: AtomicU64,
pub last_reconnect_ms: AtomicU64,
pub backend_online: AtomicU64,
pub backend_pushes_received: AtomicU64,
pub client_pushes_sent: AtomicU64,
pub client_push_send_failures: AtomicU64,
pub ordinary_client_push_backpressure_disconnects: AtomicU64,
pub qot_client_push_backpressure_drops: AtomicU64,
pub qot_client_push_backpressure_drops_by_sub_type: [AtomicU64; 18],
pub backend_pushes_cmd_quote: AtomicU64,
pub backend_pushes_cmd_trade_legacy: AtomicU64,
pub backend_pushes_cmd_trade_new: AtomicU64,
pub backend_pushes_cmd_msg_center: AtomicU64,
pub backend_pushes_cmd_other: AtomicU64,
pub backend_control_event_drops: AtomicU64,
pub message_center_async_dropped_total: AtomicU64,
pub backend_pushes_cmd_quote_by_hour: HourBreakdown,
pub backend_pushes_cmd_trade_legacy_by_hour: HourBreakdown,
pub backend_pushes_cmd_trade_new_by_hour: HourBreakdown,
pub backend_pushes_cmd_msg_center_by_hour: HourBreakdown,
pub qot_subscribe_ops: AtomicU64,
pub qot_unsubscribe_ops: AtomicU64,
pub cold_cache_wait_total: AtomicU64,
pub cold_cache_wait_hit: AtomicU64,
pub cold_cache_wait_timeout: AtomicU64,
pub resubscribe_ops: AtomicU64,
pub resubscribe_attempts: AtomicU64,
pub resubscribe_applied_keys: AtomicU64,
pub qot_push_dropped_total: AtomicU64,
pub qot_push_dropped_by_sub_type: [AtomicU64; 18],
pub keepalive_timeouts: AtomicU64,
/* private fields */
}Expand description
网关运行时监控指标
Fields§
§start_time: Instant网关启动时间
total_connections: AtomicU64累计接受的客户端连接数
total_disconnections: AtomicU64累计客户端断开数
rejected_connections: AtomicU64被拒绝的连接数(超过上限)
total_requests: AtomicU64累计处理的请求数
total_request_errors: AtomicU64累计请求错误数(handler 返回 None 或解密失败)
total_response_bytes: AtomicU64累计响应字节数
backend_reconnects: AtomicU64后端重连次数
backend_reconnect_failures: AtomicU64后端重连失败次数
last_reconnect_ms: AtomicU64最近一次重连时间 (Unix 毫秒, 0=未重连过)
backend_online: AtomicU64后端是否在线 (1=online, 0=offline)
backend_pushes_received: AtomicU64后端收到的推送数 (CMD 6212 / 4716 / 5300 等)
client_pushes_sent: AtomicU64向客户端发送的推送数
client_push_send_failures: AtomicU64向客户端推送时 client channel 已关闭导致发送失败的次数
ordinary_client_push_backpressure_disconnects: AtomicU64Ordinary push 队列饱和后首次请求关闭慢客户端的次数。
同一连接从 open 进入 closing 只计一次;与 QOT 的逐帧 drop 指标分离。
qot_client_push_backpressure_drops: AtomicU64行情推送 fanout 时 client channel 已满、仅丢该慢客户端本帧的次数。
注意: qot_push_dropped_total 统计 backend → dispatcher 队列 drop;
本 counter 统计 dispatcher → client channel backpressure,语义不同。
qot_client_push_backpressure_drops_by_sub_type: [AtomicU64; 18]按 SubType 拆分的 dispatcher → client channel backpressure drop 计数。 桶 0 = 未知 / 首推未携带 SubType;桶 1..=17 = 对应 Qot_Common.SubType。
backend_pushes_cmd_quote: AtomicU64CMD 6212 quote push 计数
backend_pushes_cmd_trade_legacy: AtomicU64CMD 4716 trade notify (legacy channel) 计数
backend_pushes_cmd_trade_new: AtomicU64CMD 14716 trade notify (v1.4.41 new channel) 计数 — tester §14 追踪
backend_pushes_cmd_msg_center: AtomicU64CMD 5300 msg-center push 计数
backend_pushes_cmd_other: AtomicU64其他未路由 CMD push 计数
backend_control_event_drops: AtomicU64Backend lifecycle control events that could not enter the dispatcher queue. This is distinct from dropping a QOT payload frame.
message_center_async_dropped_total: AtomicU64CMD5300 category=6 async option-event work that could not enter the dispatcher queue. Kept separate from quote payload and lifecycle drops.
backend_pushes_cmd_quote_by_hour: HourBreakdownCMD 6212 quote push per-UTC-hour 计数
backend_pushes_cmd_trade_legacy_by_hour: HourBreakdownCMD 4716 trade notify (legacy) per-UTC-hour 计数
backend_pushes_cmd_trade_new_by_hour: HourBreakdownCMD 14716 trade notify (new) per-UTC-hour 计数 — tester §14 主角
backend_pushes_cmd_msg_center_by_hour: HourBreakdownCMD 5300 msg-center push per-UTC-hour 计数
qot_subscribe_ops: AtomicU64行情订阅操作次数
qot_unsubscribe_ops: AtomicU64行情退订操作次数
cold_cache_wait_total: AtomicU64cold-cache wait 进入次数 (cache miss + IsSub, 触发 wait)
cold_cache_wait_hit: AtomicU64cold-cache wait 命中次数 (3s 内 push 写 cache → re-read 拿到值)
cold_cache_wait_timeout: AtomicU64cold-cache wait 超时次数 (3s timeout 仍 cache miss)
resubscribe_ops: AtomicU64重连后重新订阅次数 (legacy, == applied_keys 累加; v1.4.106 codex 0631
F5 起仍 bump 向后兼容旧 dashboard, 等价新 resubscribe_applied_keys).
resubscribe_attempts: AtomicU64v1.4.106 codex 0631 F5 [P3]: resubscribe 触发次数 (每次 reconnect / staleness loop 触发 += 1). 与 applied_keys 对比 ratio 看 partial 程度.
resubscribe_applied_keys: AtomicU64v1.4.106 codex 0631 F5 [P3]: resubscribe 真生效 keys 数 (累积). applied < attempts × global_keys → 部分 partial.
qot_push_dropped_total: AtomicU64CMD 6212 行情 push (BasicQot/OrderBook/Ticker/RT/KL/Broker/…) 因
push_tx 队列满或关闭被 drop 的总次数 (累积).
qot_push_dropped_by_sub_type: [AtomicU64; 18]按 SubType 拆分的 drop 计数 (proto Qot_Common.SubType: 0..=17, 共 18 桶). 桶 0 = “未知 / 不属于任何已知 SubType” (兜底, e.g. 拼错的 sub_type). 桶 1..=17 = 对应 SubType. v1.4.106 codex 1140 F8 加.
keepalive_timeouts: AtomicU64KeepAlive 超时断开数
Implementations§
Source§impl GatewayMetrics
impl GatewayMetrics
Sourcepub fn render_prometheus(&self) -> String
pub fn render_prometheus(&self) -> String
v1.4.90 P1-B: 输出 Prometheus text exposition 格式, 涵盖:
- 连接 / 请求 / 响应 / 后端连接基础 counter
- per-cmd_id push counter (cmd_6212_quote / cmd_4716 / cmd_14716 / cmd_5300 / cmd_other) — v1.4.83/84 telnet 已暴露, 此处补 Prometheus
- per-cmd_id × UTC-hour 24-bucket breakdown (v1.4.84 §14)
- 订阅 / KeepAlive 计数
- 延迟 p50/p95/p99 gauge (取最近 1000 样本)
注册到 [futu_auth::metrics::Registry] extension renderer 后, 在
/metrics HTTP 输出末尾自动追加. 见
install_prometheus_extension.
Source§impl GatewayMetrics
impl GatewayMetrics
pub fn new() -> Self
Sourcepub fn record_latency_ns(&self, ns: u64)
pub fn record_latency_ns(&self, ns: u64)
记录一次请求延迟 (纳秒)
Sourcepub fn record_qot_push_dropped(&self, sub_type: i32)
pub fn record_qot_push_dropped(&self, sub_type: i32)
v1.4.106 codex 1140 F8: 记录一次 qot push 被 drop (channel full / closed).
sub_type 范围 0..=17 (proto Qot_Common.SubType). 越界值归桶 0
(未知). 同时 bump 总计数 + per-sub-type 桶, 保证 dashboard 可分维度.
Sourcepub fn record_qot_client_push_backpressure_drop(&self, sub_type: i32)
pub fn record_qot_client_push_backpressure_drop(&self, sub_type: i32)
记录一次 QOT fanout 因单个客户端 channel 满而丢给该客户端的帧。
Sourcepub fn qot_push_dropped_per_sub_type(&self) -> [u64; 18]
pub fn qot_push_dropped_per_sub_type(&self) -> [u64; 18]
v1.4.106 codex 1140 F8: 读取每个 sub_type 桶的 drop 计数 (snapshot). 用于 metrics endpoint render.
pub fn qot_client_push_backpressure_drops_per_sub_type(&self) -> [u64; 18]
Sourcepub fn latency_stats(&self) -> LatencyStats
pub fn latency_stats(&self) -> LatencyStats
获取延迟统计
Sourcepub fn uptime_str(&self) -> String
pub fn uptime_str(&self) -> String
格式化运行时间
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GatewayMetrics
impl !RefUnwindSafe for GatewayMetrics
impl Send for GatewayMetrics
impl Sync for GatewayMetrics
impl Unpin for GatewayMetrics
impl UnsafeUnpin for GatewayMetrics
impl UnwindSafe for GatewayMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more