Skip to content

Commit 0e0e134

Browse files
committed
Feedback (temporary -- will squash into above)
Signed-off-by: Alec Holmes <[email protected]>
1 parent 5ab23d8 commit 0e0e134

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/flb_log.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,14 @@ void flb_log_print(int type, const char *file, int line, const char *fmt, ...)
824824
if (config != NULL && config->log != NULL) {
825825
msg_type_str = flb_log_message_type_str(type);
826826
ts = cfl_time_now();
827-
cmt_counter_inc(config->log->metrics->logs_total_counter, ts, 1, (char *[]) {msg_type_str}); // Ignoring inc error
827+
ret = cmt_counter_inc(config->log->metrics->logs_total_counter,
828+
ts,
829+
1, (char *[]) {msg_type_str});
830+
if (ret == -1) {
831+
fprintf(stderr,
832+
"[log] failed to increment log total counter for message type '%s' (error=%d)\n",
833+
msg_type_str != NULL ? msg_type_str : "unknown", ret);
834+
}
828835
}
829836

830837
n = flb_pipe_write_all(w->log[1], &msg, sizeof(msg));

tests/runtime/core_internal_logger.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ int assert_internal_log_metrics(struct http_client_ctx *http_ctx, int fail_test)
117117
/* The process startup should have logged at least 1 info log */
118118
regex = flb_regex_create(
119119
"fluentbit_logger_logs_total\\{message_type=\"info\"\\} [1-9]+[0-9]*");
120-
TEST_CHECK(regex != NULL);
120+
if (!TEST_CHECK(regex != NULL)) {
121+
TEST_MSG("Failed to create regex for info log count check");
122+
flb_http_client_destroy(http_client);
123+
return -1;
124+
}
121125
if (!TEST_CHECK(flb_regex_match(
122126
regex, http_client->resp.payload, http_client->resp.payload_size))) {
123127
TEST_MSG("response payload: %s\n", http_client->resp.payload);
@@ -164,8 +168,8 @@ static void test_internal_log_metrics()
164168

165169
/* If the assertion fails, retry in a sleep loop since the fluent-bit's HTTP server
166170
* may not be ready yet */
167-
for (i = 1; i <= attempt_count; i++) {
168-
if (assert_internal_log_metrics(http_ctx, i == attempt_count ? FLB_TRUE : FLB_FALSE)) {
171+
for (i = 0; i < attempt_count; i++) {
172+
if (assert_internal_log_metrics(http_ctx, i == (attempt_count - 1)) ) {
169173
break;
170174
}
171175
flb_time_msleep(100);

0 commit comments

Comments
 (0)