Skip to content

Commit 1ab4eb0

Browse files
Add the same error handling to Timeseries API calls as for CollectdTimeseries. (#197)
1 parent 7a15075 commit 1ab4eb0

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/write_gcm.c

+16-9
Original file line numberDiff line numberDiff line change
@@ -3981,9 +3981,9 @@ static int wg_transmit_unique_segment(
39813981
&response, ctx->agent_translation_service_url, json, headers,
39823982
STATIC_ARRAY_SIZE(headers), 0);
39833983
if (wg_result != 0) {
3984-
wg_log_json_message(ctx, "Error %d from wg_curl_get_or_post\n",
3985-
wg_result);
3986-
ERROR("%s: Error %d from wg_curl_get_or_post",
3984+
wg_log_json_message(ctx, "Error %d from wg_curl_get_or_post "
3985+
"(CollectdTimeseries)\n", wg_result);
3986+
ERROR("%s: Error %d from wg_curl_get_or_post (CollectdTimeseries)",
39873987
this_plugin_name, wg_result);
39883988
if (wg_result == -1) {
39893989
++ctx->ats_stats->api_connectivity_failures;
@@ -4028,12 +4028,19 @@ static int wg_transmit_unique_segment(
40284028
ctx, "Sending JSON (TimeseriesRequest) to %s:\n%s\n",
40294029
ctx->custom_metrics_url, json);
40304030

4031-
if (wg_curl_get_or_post(
4032-
&response, ctx->custom_metrics_url, json, headers,
4033-
STATIC_ARRAY_SIZE(headers), 0) != 0) {
4034-
wg_log_json_message(ctx, "Error contacting server.\n");
4035-
ERROR("write_gcm: Error talking to the endpoint.");
4036-
++ctx->gsd_stats->api_connectivity_failures;
4031+
int wg_result = wg_curl_get_or_post(
4032+
&response, ctx->custom_metrics_url, json, headers,
4033+
STATIC_ARRAY_SIZE(headers), 0);
4034+
if (wg_result != 0) {
4035+
wg_log_json_message(ctx, "Error %d from wg_curl_get_or_post "
4036+
"(Timeseries)\n", wg_result);
4037+
ERROR("%s: Error %d from wg_curl_get_or_post (Timeseries)",
4038+
this_plugin_name, wg_result);
4039+
if (wg_result == -1) {
4040+
++ctx->gsd_stats->api_connectivity_failures;
4041+
} else {
4042+
++ctx->gsd_stats->api_errors;
4043+
}
40374044
goto leave;
40384045
}
40394046

0 commit comments

Comments
 (0)