Skip to content

Commit

Permalink
msgpack: made the scope field optional
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich committed Apr 24, 2024
1 parent 0bb8842 commit fc02f71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ctr_decode_msgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ static int unpack_instrumentation_scope_attributes(mpack_reader_t *reader, size_

static int unpack_scope_span_instrumentation_scope(mpack_reader_t *reader, size_t index, void *ctx)
{
int result;
mpack_type_t tag_type;
int result;
struct ctrace_instrumentation_scope *instrumentation_scope;
struct ctr_msgpack_decode_context *context = ctx;
struct ctr_mpack_map_entry_callback_t callbacks[] = \
Expand All @@ -149,6 +150,12 @@ static int unpack_scope_span_instrumentation_scope(mpack_reader_t *reader, size_
{NULL, NULL}
};

tag_type = ctr_mpack_peek_type(reader);

if (tag_type == mpack_type_nil) {
return ctr_mpack_consume_nil_tag(reader);
}

instrumentation_scope = ctr_instrumentation_scope_create(NULL, NULL, 0, NULL);

if (instrumentation_scope == NULL) {
Expand All @@ -158,10 +165,12 @@ static int unpack_scope_span_instrumentation_scope(mpack_reader_t *reader, size_
ctr_scope_span_set_instrumentation_scope(context->scope_span, instrumentation_scope);

result = ctr_mpack_unpack_map(reader, callbacks, ctx);

if (result != CTR_DECODE_MSGPACK_SUCCESS) {
ctr_instrumentation_scope_destroy(context->scope_span->instrumentation_scope);
context->scope_span->instrumentation_scope = NULL;
}

return result;
}

Expand Down
6 changes: 6 additions & 0 deletions src/ctr_encode_msgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ static void pack_attributes(mpack_writer_t *writer, struct ctrace_attributes *at

static void pack_instrumentation_scope(mpack_writer_t *writer, struct ctrace_instrumentation_scope *ins_scope)
{
if (ins_scope == NULL) {
mpack_write_nil(writer);

return;
}

mpack_start_map(writer, 4);

/* name */
Expand Down

0 comments on commit fc02f71

Please sign in to comment.