[MongoDB] Track bytes, transactions and chunks replicated#575
Merged
Conversation
🦋 Changeset detectedLatest commit: 1477026 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
stevensJourney
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These replication metrics are being tracked for the various source databases:
This PR adds tracking of
powersync_data_replicated_bytes_totalandpowersync_transactions_replicated_total.Transactions replicated is informational only - it has no direct effect on performance and is not a good measurement of replication performance. It is however easy to track, and may give an indication of the write patterns on the source database.
Data replicated bytes can be a good indication of replication performance. If this metric is low while replication lag is building up, it gives an indication of a replication throughput issue, such as #573. Note that this is slightly different from bytes transferred over the network - the metric here is after decompression, and without TLS and other protocol overhead.
Chunks replicated is an internal metric in how the database batches the data. We don't directly replicate according to these chunks at the moment, but it could give useful info in some cases.
Unfortunately the byte tracking relies on internals in the MongoDB driver. We do test it properly, and gracefully handle cases where the properties are not present - for metrics it may be better to not have the metrics rather than have a hard failure. If we go with an approach such as #309 in the future, we should be able to remove these hacks.