Skip to content

Commit 671abae

Browse files
fix: otel traces flattening fix (#1196)
flatten otel traces for empty `Events` or `Links` object in span --------- Signed-off-by: Nikhil Sinha <[email protected]>
1 parent bd07a47 commit 671abae

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/otel/traces.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,15 @@ fn flatten_span_record(span_record: &Span) -> Vec<Map<String, Value>> {
293293
span_record_json.extend(flatten_status(status));
294294
}
295295

296-
for span_json in &mut span_records_json {
297-
for (key, value) in &span_record_json {
298-
span_json.insert(key.clone(), value.clone());
296+
// if span_record.events is null, code should still flatten other elements in the span record - this is handled in the if block
297+
// else block handles the flattening the span record that includes events and links records in each span record
298+
if span_records_json.is_empty() {
299+
span_records_json = vec![span_record_json];
300+
} else {
301+
for span_json in &mut span_records_json {
302+
for (key, value) in &span_record_json {
303+
span_json.insert(key.clone(), value.clone());
304+
}
299305
}
300306
}
301307

0 commit comments

Comments
 (0)