valkey-io / valkey-bloom

Rust based Valkey Module which provides a BloomFilter data type / APIs
11 stars 9 forks source link

Adding info handler, that contains two fields, num objects and memory… #19

Closed zackcam closed 3 weeks ago

zackcam commented 4 weeks ago

Added an info handler which required updating Cargo.toml to include valkey-module-macros and linkme. The info handler contains two fields bloom_total_memory_bytes and bloom_num_objects. I then updated the creation and copy methods of bloom objects to increment these values where necessary. In order to deincrement added impl Drop for bloom in order to decrease the info fields as necessary.

Testing: Created a new test file specifically for info. This test file contains for different tests: test_basic_command_metrics: This tests all create commands and non create commands to check that create commands increase the info metrics while non create dont have an influence. test_scaled_bloomfilter_metrics: Tests scaling a bloom filter increases the metrics as desired test_copy_metrics: Tests copying a bloom filter will double the metrics as desired test_save_and_restore_metrics: Tests saving and restoring a scaled and non scaled bloom filter will increase metrics as desired

zackcam commented 4 weeks ago

Accidently closed the pr, reopening with the following changes:

  1. Moved the info handler to a separate file as well as the info metrics.
  2. Created a new metric for number of filters (Changed the other metric to actually be number of bloom objects)
  3. Updated tests to include this new metric
  4. Moved an increment of metrics to be after a possible thrown error