Skip to content

MoQ stats gauge correction#209

Merged
afrind merged 1 commit into
mainfrom
bugfix/moq-stats
Jun 1, 2026
Merged

MoQ stats gauge correction#209
afrind merged 1 commit into
mainfrom
bugfix/moq-stats

Conversation

@akash-a-n
Copy link
Copy Markdown
Contributor

@akash-a-n akash-a-n commented Apr 16, 2026

removed unnecessary stats
correctly tracks the number of active publishers


This change is Reviewable

Copy link
Copy Markdown
Contributor Author

@akash-a-n akash-a-n left a comment

Choose a reason for hiding this comment

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

I have removed a bunch of namespace gauges that were inaccurately tracking the number of active publishNamespace and subscribeNamespace messages.
I have fixed a double decrement bug for pubActiveSubscribers -- (number of subscribers when session is a publisher)
I have fixed the non-decrementing issue with subActivePublishers -- (number of publishers when session is a subscriber)

@akash-a-n made 1 comment.
Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).

@gmarzot
Copy link
Copy Markdown
Contributor

gmarzot commented Apr 16, 2026

how does this PR relate to: openmoq/moxygen#148

independent?

Copy link
Copy Markdown
Contributor Author

@akash-a-n akash-a-n left a comment

Choose a reason for hiding this comment

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

The third fix - for subActivePublishers needed changes in in both the layers moqx relay and in the underlying moxygen. #148 corresponds to the underlying change.

@akash-a-n made 1 comment.
Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).

@peterchave
Copy link
Copy Markdown

peterchave commented Apr 22, 2026

Has a fix for moqx_quicActiveStreams been looked at?
That guage appears to either not be incrementing or double decrementing?

Copy link
Copy Markdown

@peterchave peterchave left a comment

Choose a reason for hiding this comment

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

:lgtm:

@peterchave reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, suhasHere, and TimEvens).

Copy link
Copy Markdown
Contributor Author

@akash-a-n akash-a-n left a comment

Choose a reason for hiding this comment

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

I'll take a look at moqx_quicActiveStreams

@akash-a-n made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, suhasHere, and TimEvens).

Copy link
Copy Markdown
Contributor Author

@akash-a-n akash-a-n left a comment

Choose a reason for hiding this comment

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

Fixed it in #256

@akash-a-n made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, suhasHere, and TimEvens).

@afrind
Copy link
Copy Markdown
Contributor

afrind commented May 23, 2026

@akash-a-n I rebased/force-pushed this for you.

Claude noticed:

Potential bug — onSubscribeError decrements without a prior increment:

  void MoQStatsCollector::SubscriberCallback::onSubscribeSuccess() {
    ++parent_.subActivePublishers_;   // incremented only on success
  }

  void MoQStatsCollector::SubscriberCallback::onSubscribeError(...) {
    --parent_.subActivePublishers_;   // decremented on error — but was never incremented!
  }

onSubscribeSuccess and onSubscribeError are mutually exclusive terminal outcomes of a SUBSCRIBE. If a subscribe
fails (error, not success), subActivePublishers_ will go negative. The decrement on onSubscribeError should be
removed.

--

Potential double-decrement: Both onUnsubscribe and onPublishDone in SubscriberCallback decrement
subActivePublishers_. If the upstream always sends PUBLISH_DONE after an unsubscribe (as the
PublisherCallback::onUnsubscribe comment suggests is the case on the pub side), this would double-decrement for
the same subscription end. Worth verifying which events actually fire together on the subscriber side.

This sounds strange - pretty sure moxygen doesn't fire publshDone after the app unsubscribes

Copy link
Copy Markdown
Contributor Author

@akash-a-n akash-a-n left a comment

Choose a reason for hiding this comment

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

I have update the code to use the new callbacks added to moxygen for tracking subscription begin and subscription end.
Tested it out with conformance script. I see all gauges fall back to 0 -- no leaks.

@akash-a-n made 1 comment.
Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on afrind, gmarzot, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).

Copy link
Copy Markdown
Contributor

@afrind afrind left a comment

Choose a reason for hiding this comment

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

@afrind reviewed 3 files and all commit messages, and made 2 comments.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on gmarzot, michalhosna, mondain, Oxyd, suhasHere, and TimEvens).


src/stats/MoQStatsCollector.cpp line 108 at r3 (raw file):

void MoQStatsCollector::PublisherCallback::onPublishNamespaceSuccess() {
  ++parent_.pubPublishNamespaceSuccess_;
  ++parent_.pubActivePublishNamespaces_;

Why did we decide to drop these gauges? Is the intent to add them back later, or have downstream systems compute them?


src/stats/MoQStatsCollector.cpp line 145 at r3 (raw file):

void MoQStatsCollector::PublisherCallback::onUnsubscribe() {
  // Downstream subscriber unsubscribed.

We may want to count the number of unsubscribe's received regardless

2. correctly tracks the number of active publishers
update: uses the new callbacks - onSubscriptionBegin and onSubscriptionEnd to track active publishers

3. Added two new metrics to count unsubscribe messages
Copy link
Copy Markdown
Contributor Author

@akash-a-n akash-a-n left a comment

Choose a reason for hiding this comment

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

@akash-a-n made 2 comments.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on gmarzot, michalhosna, mondain, Oxyd, suhasHere, and TimEvens).


src/stats/MoQStatsCollector.cpp line 108 at r3 (raw file):

Previously, afrind wrote…

Why did we decide to drop these gauges? Is the intent to add them back later, or have downstream systems compute them?

These gauges seemed redundant. They have a direct correlation with their counters.


src/stats/MoQStatsCollector.cpp line 145 at r3 (raw file):

Previously, afrind wrote…

We may want to count the number of unsubscribe's received regardless

Sure, added two new metrics to count unsubscribe messages.

Copy link
Copy Markdown
Contributor

@afrind afrind left a comment

Choose a reason for hiding this comment

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

@afrind reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on gmarzot, michalhosna, mondain, Oxyd, suhasHere, and TimEvens).

@afrind afrind merged commit 8d2b0f9 into main Jun 1, 2026
16 checks passed
@afrind afrind deleted the bugfix/moq-stats branch June 1, 2026 21:09
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.

4 participants