Skip to content

Commit

Permalink
reset error counter (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash Kumaraswamy authored and lyft-buildnotify committed Dec 13, 2016
1 parent fc31d1b commit da7ac31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/sampling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
14 changes: 10 additions & 4 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit da7ac31

Please sign in to comment.