Skip to content

Commit

Permalink
http_server: metrics: use flb_sds_cat_safe
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski committed Jul 28, 2023
1 parent 4e31618 commit d665868
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions src/http_server/api/v1/metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,44 +396,34 @@ void cb_metrics_prometheus(mk_request_t *request, void *data)
goto error;
}

sds_metric = flb_sds_cat(sds_metric, "fluentbit_", 10);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, "fluentbit_", 10) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, k.via.str.ptr, k.via.str.size);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, k.via.str.ptr, k.via.str.size) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, "_", 1);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, "_", 1) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, mk.via.str.ptr, mk.via.str.size);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, mk.via.str.ptr, mk.via.str.size) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, "_total{name=\"", 13);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, "_total{name=\"", 13) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, sk.via.str.ptr, sk.via.str.size);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, sk.via.str.ptr, sk.via.str.size) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, "\"} ", 3);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, "\"} ", 3) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, tmp, len);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, tmp, len) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, time_str, time_len);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, time_str, time_len) == -1) {
goto error;
}
sds_metric = flb_sds_cat(sds_metric, "\n", 1);
if (sds_metric == NULL) {
if (flb_sds_cat_safe(&sds_metric, "\n", 1) == -1) {
goto error;
}
metrics_arr[index] = sds_metric;
Expand Down

0 comments on commit d665868

Please sign in to comment.