From da7ac31a8917a4c9ad9c4b222aaab48ca166c5a2 Mon Sep 17 00:00:00 2001 From: Yash Kumaraswamy Date: Tue, 13 Dec 2016 10:47:57 -0800 Subject: [PATCH] reset error counter (#42) --- CMakeLists.txt | 2 +- src/sampling.c | 2 +- src/stats.c | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0797b09..275c8a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8) project(statsrelay) -set(PACKAGE_VERSION "2.3.9") +set(PACKAGE_VERSION "2.4.0") set(PACKAGE_STRING "statsrelay ${PACKAGE_VERSION}") enable_testing() diff --git a/src/sampling.c b/src/sampling.c index ce8232a..10dda06 100644 --- a/src/sampling.c +++ b/src/sampling.c @@ -170,7 +170,7 @@ static int expiry_callback(void* _s, const char* key, void* _value, void *metada time_t now = timestamp(); if ((now - bucket->last_modified_at) > (*ttl)) { - stats_debug_log("deleting key %s", key); + stats_log("deleting key %s", key); hashmap_delete(sampler->map, key); } diff --git a/src/stats.c b/src/stats.c index ce5b42e..f11b7ff 100644 --- a/src/stats.c +++ b/src/stats.c @@ -521,11 +521,10 @@ stats_server_t *stats_server_create(struct ev_loop *loop, group->flagged_lines = 0; if (dupl->sampling_threshold > 0) { - // Counter sampler, doesn't have hashmap expired key redemption - // pass in a desired ttl of -1 (never expire!). initialize_sampler(&group->count_sampler, &group->counter_sampling_watcher, group, server, dupl->sampling_threshold, dupl->sampling_window, dupl->max_counters, - false, dupl->reservoir_size, -1, -1, sampling_handler); + false, dupl->reservoir_size, dupl->hm_key_expiration_frequency_in_seconds, + dupl->hm_key_ttl_in_seconds, sampling_handler); } if (dupl->timer_sampling_threshold > 0) { @@ -535,6 +534,8 @@ stats_server_t *stats_server_create(struct ev_loop *loop, dupl->timer_flush_min_max, dupl->reservoir_size, dupl->hm_key_expiration_frequency_in_seconds, dupl->hm_key_ttl_in_seconds, timer_sampling_handler); + // gauges, doesn't have hashmap expired key redemption + // pass in a desired ttl of -1 (never expire!). initialize_sampler(&group->gauge_sampler, NULL, group, server, -1, -1, dupl->max_gauges, false, -1, -1, -1, NULL); } @@ -797,7 +798,12 @@ static int stats_relay_line(const char *line, size_t len, stats_server_t *ss, bo } else if (r == SAMPLER_SAMPLING) { continue; } - + /** + * reset the error counter + * when we start sending + * stats to the backends + */ + group->flagged_lines = 0; stats_write_to_backend(line, len, key_buffer, key_hash, key_len, group); }