write_stackdriver plugin: Set HTTP request timeout.
authorFlorian Forster <octo@collectd.org>
Tue, 9 Oct 2018 07:06:28 +0000 (09:06 +0200)
committerFlorian Forster <octo@collectd.org>
Tue, 9 Oct 2018 07:06:28 +0000 (09:06 +0200)
src/write_stackdriver.c

index eb60ea9..7be3c67 100644 (file)
@@ -187,6 +187,12 @@ static int do_post(wg_callback_t *cb, char const *url, void const *payload,
   curl_easy_setopt(cb->curl, CURLOPT_POST, 1L);
   curl_easy_setopt(cb->curl, CURLOPT_URL, url);
 
+  long timeout_ms = 2 * CDTIME_T_TO_MS(plugin_get_interval());
+  if (timeout_ms < 10000) {
+    timeout_ms = 10000;
+  }
+  curl_easy_setopt(cb->curl, CURLOPT_TIMEOUT_MS, timeout_ms);
+
   /* header */
   char *auth_header = wg_get_authorization_header(cb);
   if (auth_header == NULL) {