mirror of
https://github.com/emqx/neuron.git
synced 2026-10-27 21:41:01 +08:00
Merge pull request #2135 from eeff/v2.8
Pick to v2.8 fix(core): set metric to init value when reset
This commit is contained in:
@@ -248,6 +248,7 @@ typedef struct {
|
||||
const char * name; // NOTE: should points to string literal
|
||||
const char * help; // NOTE: should points to string literal
|
||||
neu_metric_type_e type; //
|
||||
uint64_t init; //
|
||||
uint64_t value; //
|
||||
neu_rolling_counter_t *rcnt; //
|
||||
UT_hash_handle hh; // ordered by name
|
||||
@@ -489,7 +490,7 @@ static inline void neu_node_metrics_reset(neu_node_metrics_t *node_metrics)
|
||||
HASH_LOOP(hh, node_metrics->entries, entry)
|
||||
{
|
||||
if (!neu_metric_type_no_reset(entry->type)) {
|
||||
entry->value = 0;
|
||||
entry->value = entry->init;
|
||||
if (neu_metric_type_is_rolling_counter(entry->type)) {
|
||||
neu_rolling_counter_reset(entry->rcnt);
|
||||
}
|
||||
@@ -502,7 +503,7 @@ static inline void neu_node_metrics_reset(neu_node_metrics_t *node_metrics)
|
||||
HASH_LOOP(hh, g->entries, entry)
|
||||
{
|
||||
if (!neu_metric_type_no_reset(entry->type)) {
|
||||
entry->value = 0;
|
||||
entry->value = entry->init;
|
||||
if (neu_metric_type_is_rolling_counter(entry->type)) {
|
||||
neu_rolling_counter_reset(entry->rcnt);
|
||||
}
|
||||
|
||||
@@ -313,6 +313,7 @@ int neu_metric_entries_add(neu_metric_entry_t **entries, const char *name,
|
||||
entry->value = init;
|
||||
}
|
||||
|
||||
entry->init = init;
|
||||
entry->name = name;
|
||||
entry->type = type;
|
||||
entry->help = help;
|
||||
|
||||
Reference in New Issue
Block a user