Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11 - Clean up existing module metrics #14

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions src/json/stats.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
/**
* The STATS module's main responsibility is to produce the following metrics:
* 1. Core metrics:
* The STATS module's main responsibility is to track memory usage at the level of the custom memory allocator,
* which provides the capability of tracking memory usage per JSON write operation. When a JSON key is mutated,
* we call API jsonstats_begin_track_mem() and jsonstats_end_track_mem() at the beginning and end of the write
* operation respectively, to calculate the delta of the memory usage. Then, we update the document size meta data.
*
* The module also maintains the following global info metrics:
* json_total_memory_bytes: total memory allocated to JSON objects
* json_num_documents: number of document keys in Valkey
* 2. Histograms:
* json_doc_histogram: static histogram showing document size distribution. Value of the i_th element is
* number of documents whose size fall into bucket i.
* json_read_histogram: dynamic histogram for read operations (JSON.GET and JSON.MGET). Value of the i_th
* element is number of read operations with fetched JSON size falling into bucket i.
* json_insert_histogram: dynamic histogram for insert operations (JSON.SET and JSON.ARRINSERT) that either
* insert new documents or insert values into existing documents. Value of the i_th element is number of
* insert operations with inserted values' size falling into bucket i.
* json_update_histogram: dynamic histogram for update operations (JSON.SET, JSON.STRAPPEND and
* JSON.ARRAPPEND). Value of the i_th element is number of update operations with input JSON size falling into
* bucket i.
* json_delete_histogram: dynamic histogram for delete operations (JSON.DEL, JSON.FORGET, JSON.ARRPOP and
* JSON.ARRTRIM). Value of the i_th element is number of delete operations with deleted values' size falling
* into bucket i.
*
* Histogram buckets:
* [0,256), [256,1k), [1k,4k), [4k,16k), [16k,64k), [64k,256k), [256k,1m), [1m,4m), [4m,16m), [16m,64m), [64m,INF).
* Each bucket represents a JSON size range in bytes.
joehu21 marked this conversation as resolved.
Show resolved Hide resolved
*
* To query metrics, run Valkey command:
* info modules: returns all metrics of the module
* info json_core_metrics: returns core metrics
*/
#ifndef VALKEYJSONMODULE_JSON_STATS_H_
#define VALKEYJSONMODULE_JSON_STATS_H_
Expand Down
Loading