diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2020-04-13 10:32:33 -0400 |
---|---|---|
committer | Austin S. Hemmelgarn <austin@netdata.cloud> | 2020-04-13 10:32:33 -0400 |
commit | 983a26d1a2c110b35db252b4b79c3f03eb4eeb4b (patch) | |
tree | 85d42c30bc81514bd5c18aa564497e439290523b /exporting/send_data.c | |
parent | 5a12b4a7e42587058b9b42871a1316545d527a57 (diff) |
Revert "Revert changes since v1.21 in pereparation for hotfix release."
This reverts commit e2874320fc027f7ab51ab3e115d5b1889b8fd747.
Diffstat (limited to 'exporting/send_data.c')
-rw-r--r-- | exporting/send_data.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/exporting/send_data.c b/exporting/send_data.c index 6315a7d1bf..8875065f2b 100644 --- a/exporting/send_data.c +++ b/exporting/send_data.c @@ -57,8 +57,8 @@ void simple_connector_receive_response(int *sock, struct instance *instance) if (likely(r > 0)) { // we received some data response->len += r; - stats->chart_received_bytes += r; - stats->chart_receptions++; + stats->received_bytes += r; + stats->receptions++; } else if (r == 0) { error("EXPORTING: '%s' closed the socket", instance->config.destination); close(*sock); @@ -109,9 +109,9 @@ void simple_connector_send_buffer(int *sock, int *failures, struct instance *ins if(written != -1 && (size_t)written == len) { // we sent the data successfully - stats->chart_transmission_successes++; - stats->chart_sent_bytes += written; - stats->chart_sent_metrics = stats->chart_buffered_metrics; + stats->transmission_successes++; + stats->sent_bytes += written; + stats->sent_metrics = stats->buffered_metrics; // reset the failures count *failures = 0; @@ -126,10 +126,10 @@ void simple_connector_send_buffer(int *sock, int *failures, struct instance *ins instance->config.destination, len, written); - stats->chart_transmission_failures++; + stats->transmission_failures++; if(written != -1) - stats->chart_sent_bytes += written; + stats->sent_bytes += written; // increment the counter we check for data loss (*failures)++; @@ -160,6 +160,19 @@ void simple_connector_worker(void *instance_p) int failures = 0; while(!netdata_exit) { + + // reset the monitoring chart counters + stats->received_bytes = + stats->sent_bytes = + stats->sent_metrics = + stats->lost_metrics = + stats->receptions = + stats->transmission_successes = + stats->transmission_failures = + stats->data_lost_events = + stats->lost_bytes = + stats->reconnects = 0; + // ------------------------------------------------------------------------ // if we are connected, receive a response, without blocking @@ -179,7 +192,7 @@ void simple_connector_worker(void *instance_p) &reconnects, NULL, 0); - stats->chart_reconnects += reconnects; + stats->reconnects += reconnects; } if(unlikely(netdata_exit)) break; @@ -194,12 +207,31 @@ void simple_connector_worker(void *instance_p) simple_connector_send_buffer(&sock, &failures, instance); } else { error("EXPORTING: failed to update '%s'", instance->config.destination); - stats->chart_transmission_failures++; + stats->transmission_failures++; // increment the counter we check for data loss failures++; } + BUFFER *buffer = instance->buffer; + + if (failures > instance->config.buffer_on_failures) { + stats->lost_bytes += buffer_strlen(buffer); + error( + "EXPORTING: connector instance %s reached %d exporting failures. " + "Flushing buffers to protect this host - this results in data loss on server '%s'", + instance->config.name, failures, instance->config.destination); + buffer_flush(buffer); + failures = 0; + stats->data_lost_events++; + stats->lost_metrics = stats->buffered_metrics; + } + + send_internal_metrics(instance); + + if(likely(buffer_strlen(buffer) == 0)) + stats->buffered_metrics = 0; + uv_mutex_unlock(&instance->mutex); #ifdef UNIT_TESTING |