diff options
author | Vladimir Kobal <vlad@prokk.net> | 2021-04-21 19:02:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 19:02:32 +0300 |
commit | 0d5781ed7c19bc49a241defeeb8273c368be0396 (patch) | |
tree | fa8c859589e74aa515a650f2800100b3ace9c151 | |
parent | a1ce482f3e336dbabe1b12b92f6339af6a2bbbf8 (diff) |
Allow the remote write configuration have multiple destinations (#11005)
-rw-r--r-- | exporting/exporting_engine.h | 4 | ||||
-rw-r--r-- | exporting/prometheus/remote_write/remote_write.c | 2 | ||||
-rw-r--r-- | exporting/send_data.c | 7 | ||||
-rw-r--r-- | exporting/tests/test_exporting_engine.c | 6 |
4 files changed, 15 insertions, 4 deletions
diff --git a/exporting/exporting_engine.h b/exporting/exporting_engine.h index 1edd283f78..1ad6e6856f 100644 --- a/exporting/exporting_engine.h +++ b/exporting/exporting_engine.h @@ -98,9 +98,13 @@ struct simple_connector_buffer { struct simple_connector_buffer *next; }; +#define CONNECTED_TO_MAX 1024 + struct simple_connector_data { void *connector_specific_data; + char connected_to[CONNECTED_TO_MAX]; + size_t total_buffered_metrics; BUFFER *header; diff --git a/exporting/prometheus/remote_write/remote_write.c b/exporting/prometheus/remote_write/remote_write.c index f844e3e498..986ad9f0ea 100644 --- a/exporting/prometheus/remote_write/remote_write.c +++ b/exporting/prometheus/remote_write/remote_write.c @@ -31,7 +31,7 @@ void prometheus_remote_write_prepare_header(struct instance *instance) "Content-Length: %zu\r\n" "\r\n", connector_specific_config->remote_write_path, - instance->config.destination, + simple_connector_data->connected_to, buffer_strlen(simple_connector_data->last_buffer->buffer)); } diff --git a/exporting/send_data.c b/exporting/send_data.c index 1e932e98ff..0f5e419296 100644 --- a/exporting/send_data.c +++ b/exporting/send_data.c @@ -314,7 +314,12 @@ void simple_connector_worker(void *instance_p) size_t reconnects = 0; sock = connect_to_one_of( - instance->config.destination, connector_specific_config->default_port, &timeout, &reconnects, NULL, 0); + instance->config.destination, + connector_specific_config->default_port, + &timeout, + &reconnects, + connector_specific_data->connected_to, + CONNECTED_TO_MAX); #ifdef ENABLE_HTTPS if (exporting_tls_is_enabled(instance->config.type, options) && sock != -1) { if (netdata_exporting_ctx) { diff --git a/exporting/tests/test_exporting_engine.c b/exporting/tests/test_exporting_engine.c index beb5691d8f..73fd3ca668 100644 --- a/exporting/tests/test_exporting_engine.c +++ b/exporting/tests/test_exporting_engine.c @@ -618,6 +618,7 @@ static void test_simple_connector_worker(void **state) simple_connector_data->buffer = buffer_create(0); simple_connector_data->last_buffer->header = buffer_create(0); simple_connector_data->last_buffer->buffer = buffer_create(0); + strcpy(simple_connector_data->connected_to, "localhost"); buffer_sprintf(simple_connector_data->last_buffer->header, "test header"); buffer_sprintf(simple_connector_data->last_buffer->buffer, "test buffer"); @@ -626,8 +627,8 @@ static void test_simple_connector_worker(void **state) expect_string(__wrap_connect_to_one_of, destination, "localhost"); expect_value(__wrap_connect_to_one_of, default_port, 2003); expect_not_value(__wrap_connect_to_one_of, reconnects_counter, 0); - expect_value(__wrap_connect_to_one_of, connected_to, 0); - expect_value(__wrap_connect_to_one_of, connected_to_size, 0); + expect_string(__wrap_connect_to_one_of, connected_to, "localhost"); + expect_value(__wrap_connect_to_one_of, connected_to_size, CONNECTED_TO_MAX); will_return(__wrap_connect_to_one_of, 2); expect_function_call(__wrap_send); @@ -1170,6 +1171,7 @@ static void test_prometheus_remote_write_prepare_header(void **state) simple_connector_data->last_buffer = callocz(1, sizeof(struct simple_connector_buffer)); simple_connector_data->last_buffer->header = buffer_create(0); simple_connector_data->last_buffer->buffer = buffer_create(0); + strcpy(simple_connector_data->connected_to, "localhost"); buffer_sprintf(simple_connector_data->last_buffer->buffer, "test buffer"); |