Skip to content

Commit

Permalink
encode: opentelemetry: release spans on exception (CID 507645)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Oct 14, 2024
1 parent 9e4e1e2 commit aa0c168
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ctr_encode_opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ static inline void otlp_array_destroy(Opentelemetry__Proto__Common__V1__ArrayVal

static inline void otlp_kvpair_list_destroy(Opentelemetry__Proto__Common__V1__KeyValue **pair_list, size_t entry_count);

static void destroy_spans(Opentelemetry__Proto__Trace__V1__Span **spans, size_t count);

static inline void otlp_kvpair_destroy(Opentelemetry__Proto__Common__V1__KeyValue *kvpair)
{
if (kvpair != NULL) {
Expand Down Expand Up @@ -425,8 +427,7 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *ctr_variant_string_to_

if (result->string_value == NULL) {
otlp_any_value_destroy(result);

result = NULL;
return NULL;
}
}

Expand Down Expand Up @@ -484,8 +485,8 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *ctr_variant_binary_to_

if (result->bytes_value.data == NULL) {
otlp_any_value_destroy(result);

result = NULL;

}

memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len);
Expand Down Expand Up @@ -884,6 +885,9 @@ static Opentelemetry__Proto__Trace__V1__Span **set_spans(struct ctrace_scope_spa

otel_span = initialize_span();
if (!otel_span) {
if (span_index > 0) {
destroy_spans(spans, span_index);
}
return NULL;
}

Expand Down

0 comments on commit aa0c168

Please sign in to comment.