Skip to content

Commit

Permalink
Merge pull request #1430 from eeff/v2.5
Browse files Browse the repository at this point in the history
Pick to 2.5 feat(metrics): reset metric values to zero when node stopped
  • Loading branch information
fengzeroz authored Aug 7, 2023
2 parents f93bf71 + 84c117c commit c789ffc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/adapter/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,22 @@ static int adapter_update_metric(neu_adapter_t *adapter,
return 0;
}

static void adapter_reset_metrics(neu_adapter_t *adapter)
{
neu_metric_entry_t *entry = NULL;
if (NULL == adapter->metrics) {
return;
}

HASH_LOOP(hh, adapter->metrics->entries, entry) { entry->value = 0; }

neu_group_metrics_t *g = NULL;
HASH_LOOP(hh, adapter->metrics->group_metrics, g)
{
HASH_LOOP(hh, g->entries, entry) { entry->value = 0; }
}
}

static int adapter_command(neu_adapter_t *adapter, neu_reqresp_head_t header,
void *data)
{
Expand Down Expand Up @@ -1056,6 +1072,7 @@ int neu_adapter_stop(neu_adapter_t *adapter)
if (error == NEU_ERR_SUCCESS) {
adapter->state = NEU_NODE_RUNNING_STATE_STOPPED;
adapter_storage_state(adapter->name, adapter->state);
adapter_reset_metrics(adapter);
}

return error;
Expand Down

0 comments on commit c789ffc

Please sign in to comment.