Skip to main content

GatewayMetrics

Struct GatewayMetrics 

Source
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: AtomicU64

CMD 6212 quote push 计数

§backend_pushes_cmd_trade_legacy: AtomicU64

CMD 4716 trade notify (legacy channel) 计数

§backend_pushes_cmd_trade_new: AtomicU64

CMD 14716 trade notify (v1.4.41 new channel) 计数 — tester §14 追踪

§backend_pushes_cmd_msg_center: AtomicU64

CMD 5300 msg-center push 计数

§backend_pushes_cmd_other: AtomicU64

其他未路由 CMD push 计数

§backend_pushes_cmd_quote_by_hour: HourBreakdown

CMD 6212 quote push per-UTC-hour 计数

§backend_pushes_cmd_trade_legacy_by_hour: HourBreakdown

CMD 4716 trade notify (legacy) per-UTC-hour 计数

§backend_pushes_cmd_trade_new_by_hour: HourBreakdown

CMD 14716 trade notify (new) per-UTC-hour 计数 — tester §14 主角

§backend_pushes_cmd_msg_center_by_hour: HourBreakdown

CMD 5300 msg-center push per-UTC-hour 计数

§qot_subscribe_ops: AtomicU64

行情订阅操作次数

§qot_unsubscribe_ops: AtomicU64

行情退订操作次数

§cold_cache_wait_total: AtomicU64

cold-cache wait 进入次数 (cache miss + IsSub, 触发 wait)

§cold_cache_wait_hit: AtomicU64

cold-cache wait 命中次数 (3s 内 push 写 cache → re-read 拿到值)

§cold_cache_wait_timeout: AtomicU64

cold-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: AtomicU64

v1.4.106 codex 0631 F5 [P3]: resubscribe 触发次数 (每次 reconnect / staleness loop 触发 += 1). 与 applied_keys 对比 ratio 看 partial 程度.

§resubscribe_applied_keys: AtomicU64

v1.4.106 codex 0631 F5 [P3]: resubscribe 真生效 keys 数 (累积). applied < attempts × global_keys → 部分 partial.

§qot_push_dropped_total: AtomicU64

CMD 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: AtomicU64

KeepAlive 超时断开数

Implementations§

Source§

impl GatewayMetrics

Source

pub fn new() -> Self

Source

pub fn record_latency_ns(&self, ns: u64)

记录一次请求延迟 (纳秒)

Source

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 可分维度.

Source

pub fn qot_push_dropped_per_sub_type(&self) -> [u64; 18]

v1.4.106 codex 1140 F8: 读取每个 sub_type 桶的 drop 计数 (snapshot). 用于 metrics endpoint render.

Source

pub fn latency_stats(&self) -> LatencyStats

获取延迟统计

Source

pub fn uptime_str(&self) -> String

格式化运行时间

Source

pub fn report(&self) -> String

生成 telnet 可展示的指标报告

Source§

impl GatewayMetrics

Source

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.

Trait Implementations§

Source§

impl Default for GatewayMetrics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more