pub struct GatewayMetrics {Show 33 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 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_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向客户端发送的推送数
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_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
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 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.
Sourcepub fn latency_stats(&self) -> LatencyStats
pub fn latency_stats(&self) -> LatencyStats
获取延迟统计
Sourcepub fn uptime_str(&self) -> String
pub fn uptime_str(&self) -> String
格式化运行时间
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.