Expand description
Publish and consume MoQ traffic stats.
moq-net collects per-session traffic counters in a
stats::Registry; this crate turns that
registry into MoQ broadcasts and back:
Producerdrains a registry on an interval and publishes the counters as JSON tracks on an origin.Consumersubscribes to one published stats broadcast and yields typed frames, for aggregators, dashboards, and billing meters.aggregate::Consumerfolds a whole group’s per-node broadcasts into one merged view, so a downstream sees a project’s total live traffic as if it came from a single node.
§Wire format
A Producer publishes one broadcast per node at <prefix>/node/<node>
(default prefix .stats), or one per group of leading broadcast-path
segments at <prefix>/<group>/node/<node>; parse announce paths back with
parse_node_path. Each Tier carries publisher.json,
subscriber.json, and sessions.json tracks of cumulative Traffic and
Presence counters, plus .json.z siblings encoded with
moq_json::snapshot; compute names with traffic_track /
sessions_track. The full contract (paths, tracks, both encodings, and
counter semantics) is at https://doc.moq.dev/concept/stats.
Re-exports§
Modules§
- aggregate
- The aggregating half: fold a group’s per-node stats broadcasts into one view.
- consume
- The consuming half: typed readers over one published stats broadcast.
- produce
- The publishing half: drain a
Registryon an interval into stats tracks.
Structs§
- Handle
- Counter collection, re-exported from
moq_net::statsso stats consumers can depend on this crate alone. Tier-scoped wrapper aroundRegistry. Whatcrate::Client::with_statsandcrate::Server::with_statsaccept. Cheap to clone. - Node
Path - A parsed stats broadcast path:
<prefix>[/<group>]/node[/<node>]. Seeparse_node_path. - Presence
- Counter collection, re-exported from
moq_net::statsso stats consumers can depend on this crate alone. Connected-session presence for one slice (an auth root on a tier, or any sum of such slices): cumulative connects and disconnects. `sessions_started - Registry
- Counter collection, re-exported from
moq_net::statsso stats consumers can depend on this crate alone. Counter collection registry. Cheap to clone (Arcinside for the shared state). One instance per relay; sessions get tier-scoped handles viaRegistry::tier. Themoq-statscrate drains it withRegistry::reportto publish the counters as MoQ broadcasts. - Tier
- Counter collection, re-exported from
moq_net::statsso stats consumers can depend on this crate alone. Traffic-class label that selects which counter set a session’s bumps record in, so a singleRegistrycan split customer-facing, cluster-peer, regional, etc. traffic. Each tracked broadcast keeps a per-tier counter set on both its publisher and subscriber sides. - Traffic
- Counter collection, re-exported from
moq_net::statsso stats consumers can depend on this crate alone. A cumulative traffic counter readout for one slice (a broadcast on a(tier, role), or any sum of such slices).
Enums§
- Error
- Errors produced while publishing or consuming stats.
- Role
- Counter collection, re-exported from
moq_net::statsso stats consumers can depend on this crate alone. Publisher (egress) vs subscriber (ingress) side of a broadcast, used as a label on aSnapshottraffic row. The internal bump paths track the side statically, so this only surfaces on the aggregate read side.
Constants§
- COMPRESSED_
SUFFIX - Suffix appended to a plain track name for its compressed sibling.
Functions§
- parse_
node_ path - Parse a stats broadcast announce path published under
prefixwith the given groupingdepth, splitting it into its group and node parts. - sessions_
track - The sessions track name for a tier:
sessions.jsonon the default tier,<tier>/sessions.jsonon a named one, plusCOMPRESSED_SUFFIXwhencompressed. - traffic_
track - The traffic track name for a tier and role:
<role>.jsonat the prefix root on the default tier (publisher.json/subscriber.json),<tier>/<role>.jsonon a named one, plusCOMPRESSED_SUFFIXwhencompressed.
Type Aliases§
- Result
- A
Resultusing this crate’sError. - Sessions
Frame - One frame off a sessions track: connect/disconnect gauges keyed by auth root.
- Traffic
Frame - One frame off a traffic track: cumulative counters keyed by broadcast path.