agent: Add more Rust code examples, update TODO check (#28737)

Release Notes:

- N/A
This commit is contained in:
Thomas Mickley-Doyle 2025-04-15 11:52:08 -05:00 committed by GitHub
parent d0f806456c
commit b1e4e6048a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 142 additions and 2 deletions

View file

@ -0,0 +1,3 @@
url = "https://github.com/clockworklabs/SpacetimeDB.git"
revision = "13dfb031351c3adf308c74b2a085ca15aa797db1"
language_extension = "rs"

View file

@ -0,0 +1,6 @@
1. The function `report_data_size` has been refactored to have a more accessible visibility by changing from `pub(super)` to `pub` in the `CommittedState` struct, making it usable outside of its previous scope.
2. The `record_tx_metrics` function has been modified to remove the previously commented-out code that invoked `report_data_size` from `committed_state`. The intention to possibly inline this functionality or refactor the metrics updates is noted.
3. A new function `update_data_size_metrics` has been introduced in the `RelationalDB` struct to simplify calling the `report_data_size` method, enhancing clarity and direct usage within the database context.
4. The `storage_monitor` function has been renamed and refactored to `metric_reporter`, which is tasked with collecting disk usage statistics and invoking `update_data_size_metrics` for database state updates.
5. Various asynchronous operations involving time intervals for disk usage measurement and reporting have been restructured for improved metric collection, reducing unnecessary operations and improving clarity.
6. Comments and TODOs are placed where further improvements, such as adding heap usage metrics, are possible, guiding future enhancements.

View file

@ -0,0 +1 @@
I'd like to refactor and improve the metric collection system in the database layer. Specifically, please refactor the `report_data_size` function to make it publicly accessible by changing its visibility from `pub(super)` to `pub`. Then, remove the commented-out `report_data_size` invocation from `record_tx_metrics` in the `datastore.rs` file and ensure that metric collection is more streamlined. Add a new function in the `RelationalDB` struct named `update_data_size_metrics` to simplify invoking `report_data_size` and enhance its usage across the code. Finally, refactor the `storage_monitor` function by renaming it to `metric_reporter`, and ensure that it periodically collects disk usage statistics and updates data size metrics. Additionally, leave a TODO in the code for adding heap usage metrics in the future. Please ensure that these changes maintain the core functionality while improving the overall organization and clarity of the code.