Skip to content

Commit

Permalink
Auto-Merge pull request #4268 from octo/6/format_stackdriver
Browse files Browse the repository at this point in the history
Automatically merged due to "Automerge" label
  • Loading branch information
collectd-bot committed Feb 1, 2024
2 parents 89decd7 + 0f36c32 commit 262d228
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/utils/format_stackdriver/format_stackdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ static void sd_output_reset_staged(sd_output_t *out) /* {{{ */
sfree(key);
} /* }}} void sd_output_reset_staged */

static void reset(sd_output_t *out) {
sd_output_reset_staged(out);

yajl_gen_clear(out->gen); /* empty generator buffer */
yajl_gen_reset(out->gen, NULL); /* reset generator state */

sd_output_initialize(out);
}

sd_output_t *sd_output_create(sd_resource_t *res) /* {{{ */
{
sd_output_t *out = calloc(1, sizeof(*out));
Expand Down Expand Up @@ -549,6 +558,7 @@ int sd_output_add(sd_output_t *out, metric_t const *m) {
if ((status != 0) && (status != EAGAIN)) {
ERROR("sd_output_add: format_time_series failed with status %d.", status);
STRBUF_DESTROY(id);
reset(out);
return status;
}

Expand Down Expand Up @@ -597,12 +607,7 @@ char *sd_output_reset(sd_output_t *out) /* {{{ */
yajl_gen_get_buf(out->gen, &json_buffer, &(size_t){0});
char *ret = strdup((void const *)json_buffer);

sd_output_reset_staged(out);

yajl_gen_free(out->gen);
out->gen = yajl_gen_alloc(/* funcs = */ NULL);

sd_output_initialize(out);
reset(out);

return ret;
} /* }}} char *sd_output_reset */
Expand Down

0 comments on commit 262d228

Please sign in to comment.