Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opentelemetry: fixed scope member handling #53

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion src/ctr_decode_opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,10 @@ int ctr_decode_opentelemetry_create(struct ctrace **out_ctr,

scope_span = ctr_scope_span_create(resource_span);
ctr_scope_span_set_schema_url(scope_span, otel_scope_span->schema_url);
ctr_scope_span_set_scope(scope_span, otel_scope_span->scope);

if (otel_scope_span->scope != NULL) {
ctr_scope_span_set_scope(scope_span, otel_scope_span->scope);
}

for (span_index = 0; span_index < otel_scope_span->n_spans; span_index++) {
otel_span = otel_scope_span->spans[span_index];
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
Loading