Skip to content

Minimal observability metrics (relay & client)#9

Open
fcancela wants to merge 13 commits intomainfrom
feat/observability
Open

Minimal observability metrics (relay & client)#9
fcancela wants to merge 13 commits intomainfrom
feat/observability

Conversation

@fcancela
Copy link

@fcancela fcancela commented Jan 16, 2026

Summary

This PR adds the smallest reviewable observability surface for the MoQ demo: a reusable application-level byte accounting hook in moq-lite, minimal relay-side counters exposed via a Prometheus-style /metrics endpoint, and minimal browser-side OTLP metrics for connection type + time-to-first-frame.

What’s included

  • moq-lite: optional Stats sink for application payload byte accounting
    • Adds Stats trait and connect_with_stats / accept_with_stats plumbing
    • Wires byte accounting into publisher/subscriber read/write hot paths
  • moq-native: adds Request::accept_with_stats(...) to pass the sink through to moq-lite
  • moq-relay: minimal counters + /metrics
    • moq_relay_active_sessions{transport="webtransport|websocket"} (gauge)
    • moq_relay_app_bytes_sent_total{transport=...} (counter)
    • moq_relay_app_bytes_received_total{transport=...} (counter)
  • js/hang: metrics-only OTLP HTTP export (no tracing)
    • moq_client_connections_total{transport=...} (counter)
    • moq_client_startup_time_seconds{track_type="audio|video"} (histogram, time-to-first-frame from track subscription start)
  • js/lite: adds a tiny onConnectionType(cb) callback hook so hang can record webtransport vs websocket
  • js/hang video stats: framesDecoded is counted on the decoder output path; removed the unimplemented framesDropped

What’s intentionally out of scope

  • Grafana dashboards / Tempo / Loki / collector compose stack
  • Traces/log export
  • Higher-cardinality media QoE metrics (rebuffer, decode timings, etc.)

How to test (local)

  1. Run the demo as usual
  2. Verify relay metrics are present and changing:
curl -sS http://localhost:4443/metrics | grep '^moq_relay_'

You should see moq_relay_app_bytes_* increasing while playback is active.

  1. (Optional) If you have an OTLP HTTP collector at :4318, the browser will POST metrics to:
  • http://<collector>:4318/v1/metrics

Notes for reviewers

  • The moq-lite::Stats hook is intentionally generic and non-blocking (callers can implement with atomics).
  • Relay /metrics uses low-cardinality labels only (transport), matching Prometheus best practices.

@gemini-code-assist
Copy link

Summary of Changes

Hello @fcancela, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces foundational observability capabilities across the MoQ demo stack. It provides a minimal yet reviewable surface for tracking key operational metrics, such as application-level byte usage and connection types, on both the relay and client sides. The changes aim to enable basic monitoring and performance analysis of the MoQ system, setting the groundwork for future, more comprehensive telemetry without adding excessive complexity at this stage.

Highlights

  • Application-level Byte Accounting: Introduced a generic and non-blocking Stats trait in moq-lite to enable application payload byte accounting for both transmitted and received data, allowing for deeper insights into data flow without transport-level retransmissions.
  • Relay-side Prometheus Metrics: Implemented minimal relay-side counters for active sessions and application bytes sent/received, exposed via a Prometheus-style /metrics endpoint. These metrics use low-cardinality labels for best practices.
  • Client-side OpenTelemetry Metrics: Added client-side OpenTelemetry (OTLP) metrics for connection type (moq_client_connections_total) and startup time (moq_client_startup_time_seconds). These metrics are exported via HTTP to a configurable OTLP endpoint.
  • Connection Type Tracking: A new onConnectionType callback hook was added to js/lite to allow client-side code to determine and record whether a connection is established over WebTransport or WebSocket.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR introduces a minimal but effective observability layer for both the client and relay, which is a great addition. The use of OpenTelemetry on the client and a Prometheus-style endpoint on the relay are solid choices. The Rust implementation for stats collection is well-designed, using a clean trait and RAII for session tracking. The TypeScript implementation is also good, but I've found a few issues with metric correctness on the client-side that should be addressed. Specifically, there's a redundant startup time metric, and the framesDecoded and framesDropped stats are not implemented correctly. I've left detailed comments on these points. Overall, this is a strong contribution that lays a good foundation for future observability work.

@fcancela fcancela marked this pull request as ready for review January 19, 2026 14:56
@fcancela fcancela changed the title Minimal observability hooks + demo metrics (relay /metrics, client OTLP) Minimal observability metrics (relay & client) Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant