feat: restore federation metrics lost in native federation migration - #41959
feat: restore federation metrics lost in native federation migration#41959KevLehman wants to merge 16 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-9.0.0 #41959 +/- ##
================================================
Coverage ? 69.52%
================================================
Files ? 4224
Lines ? 167736
Branches ? 29864
================================================
Hits ? 116616
Misses ? 45977
Partials ? 5143
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
438d65b to
6152fca
Compare
Proposed changes (including videos or screenshots)
Restores the federation statistics that regressed in the migration from the old federation implementations to native federation. Three claims fixed:
externalConnectedServersalways reported{quantity: 0, servers: []}. Its backing query,Rooms.countDistinctFederationRoomsExcluding, was a// TODO implementstub returning[]. It now counts remote homeservers fromrocketchat_federation_servers(the federation-sdk signing-key cache — one doc per remote homeserver we verified), excludingFederation_Service_Domain. The dead stub and itsIRoomsModeltyping are removed.Federation event volume was dropped entirely. The old federation reported
federationOverviewData.numberOfEvents(lifetime event-store count); the native stack persists a full PDU store inrocketchat_federation_eventsbut never reported it. NewamountOfFederationEventsfield onmatrixFederationstatistics, fed byestimatedDocumentCount()(collection metadata, no scan).amountOfExternalUsersover-counted on upgraded workspaces.Users.countFederatedExternalUserscounted{federated: true}, which includes stale users created by the removed matrix bridge (federated: truewith nofederationsubdoc — verified against 6.9.7'sFederatedUser.getStorageRepresentation). The query now also requiresfederation.version, which only native federation writes. LDAP-provisioned federated users keep being counted: they get the full native subdoc and are genuinely remote (getFederationHomeServeronly fires when the mapped homeserver differs from the local domain).Missing-collection safety:
distinct/estimatedDocumentCounton nonexistent collections return[]/0, so workspaces that never federated report zeros.Issue(s)
Follow-up to #37059 and #41940 (old federation removals).
Steps to test or reproduce
POST /api/v1/statistics.generate(or wait for the usage report cron) on one of them.matrixFederation.externalConnectedServerslists the peer homeserver,amountOfFederationEvents> 0, andamountOfExternalUserscounts only users with a nativefederationsubdoc.Further comments
The raw
db.collection()reads in the statistics adapter are deliberate:rocketchat_federation_serversandrocketchat_federation_eventsare owned by@rocket.chat/federation-sdk(no model exists on the Rocket.Chat side), and creating models for two read-only counts wasn't worth the ceremony.