Skip to content

Commit e65b7b9

Browse files
committed
metrics: add flb_metrics_is_empty() helper
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 92d0cbe commit e65b7b9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

include/fluent-bit/flb_metrics.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
#include <cmetrics/cmt_decode_statsd.h>
4343
#include <cmetrics/cmt_filter.h>
4444

45+
/*
46+
* v1 HTTP endpoint metrics
47+
* ------------------------
48+
* These are functions that are not part of the CMetrics library, its' the old interface
49+
* to ship internal metrics which is part of the v1 HTTP endpoint.
50+
*/
51+
4552
/* Metrics IDs for general purpose (used by core and Plugins */
4653
#define FLB_METRIC_N_RECORDS 0
4754
#define FLB_METRIC_N_BYTES 1
@@ -85,6 +92,10 @@ int flb_metrics_dump_values(char **out_buf, size_t *out_size,
8592
struct flb_metrics *me);
8693
int flb_metrics_destroy(struct flb_metrics *metrics);
8794
int flb_metrics_fluentbit_add(struct flb_config *ctx, struct cmt *cmt);
95+
/* ! end of v1 HTTP endpoint metrics */
96+
97+
/* General metrics utilities */
98+
bool flb_metrics_is_empty(struct cmt *cmt);
8899

89100
#endif
90101
#endif /* FLB_HAVE_METRICS */

src/flb_metrics.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,12 @@ int flb_metrics_fluentbit_add(struct flb_config *ctx, struct cmt *cmt)
376376

377377
return 0;
378378
}
379+
380+
bool flb_metrics_is_empty(struct cmt *cmt)
381+
{
382+
return cfl_list_is_empty(&cmt->counters) &&
383+
cfl_list_is_empty(&cmt->gauges) &&
384+
cfl_list_is_empty(&cmt->histograms) &&
385+
cfl_list_is_empty(&cmt->summaries) &&
386+
cfl_list_is_empty(&cmt->untypeds);
387+
}

0 commit comments

Comments
 (0)