Skip to content

Commit 6240604

Browse files
committed
fixup! http_server/health: Implement throughput health check
Address Leonardo review: Extract flb_time_to_seconds Signed-off-by: Thiago Padilha <[email protected]>
1 parent 968a2e1 commit 6240604

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

include/fluent-bit/flb_time.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ int flb_time_get(struct flb_time *tm);
7676
int flb_time_msleep(uint32_t ms);
7777
double flb_time_to_double(struct flb_time *tm);
7878
uint64_t flb_time_to_nanosec(struct flb_time *tm);
79+
uint64_t flb_time_to_seconds(struct flb_time *tm);
7980
int flb_time_add(struct flb_time *base, struct flb_time *duration,
8081
struct flb_time *result);
8182
int flb_time_diff(struct flb_time *time1,

src/flb_time.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ uint64_t flb_time_to_nanosec(struct flb_time *tm)
9696
return (((uint64_t)tm->tm.tv_sec * 1000000000L) + tm->tm.tv_nsec);
9797
}
9898

99+
uint64_t flb_time_to_seconds(struct flb_time *tm)
100+
{
101+
return (uint64_t)tm->tm.tv_sec;
102+
}
103+
99104
int flb_time_add(struct flb_time *base, struct flb_time *duration, struct flb_time *result)
100105
{
101106
if (base == NULL || duration == NULL|| result == NULL) {

src/http_server/api/v1/health.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static int check_throughput_health(uint64_t in_records,
324324
bool rv;
325325

326326
flb_time_get(&tp);
327-
timestamp_seconds = flb_time_to_nanosec(&tp) / 1000000000;
327+
timestamp_seconds = flb_time_to_seconds(&tp);
328328

329329
if (mk_list_is_empty(sample_list) != 0) {
330330
last_sample = mk_list_entry_last(sample_list,

0 commit comments

Comments
 (0)