Skip to content

Commit

Permalink
decode: msgpack: allow histograms with no buckets to be serialized
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <leonardo@calyptia.com>
  • Loading branch information
leonardo-albertovich authored and edsiper committed Mar 31, 2023
1 parent db3cc2c commit b351beb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cmt_encode_msgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,17 @@ static void pack_header(mpack_writer_t *writer, struct cmt *cmt, struct cmt_map
/* 'buckets' (histogram buckets) */
mpack_write_cstr(writer, "buckets");

mpack_start_array(writer, histogram->buckets->count);
if (histogram->buckets != NULL) {
mpack_start_array(writer, histogram->buckets->count);

for (index = 0 ;
index < histogram->buckets->count ;
index++) {
mpack_write_double(writer, histogram->buckets->upper_bounds[index]);
for (index = 0 ;
index < histogram->buckets->count ;
index++) {
mpack_write_double(writer, histogram->buckets->upper_bounds[index]);
}
}
else {
mpack_start_array(writer, 0);
}

mpack_finish_array(writer);
Expand Down

0 comments on commit b351beb

Please sign in to comment.