From 33270fcdab3c3abf9f3d3b61d520913ed6a616e1 Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Mon, 11 Nov 2024 08:02:35 -0700 Subject: [PATCH 1/2] pkg/otel/trace/arrow: Set parentSpanID NULL if empty bytes --- pkg/otel/traces/arrow/traces.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/otel/traces/arrow/traces.go b/pkg/otel/traces/arrow/traces.go index 89814218..52338a09 100644 --- a/pkg/otel/traces/arrow/traces.go +++ b/pkg/otel/traces/arrow/traces.go @@ -278,7 +278,11 @@ func (b *TracesBuilder) Append(traces ptrace.Traces) error { b.sib.Append(sib[:]) b.tsb.AppendNonEmpty(span.Span.TraceState().AsRaw()) psib := span.Span.ParentSpanID() - b.psib.Append(psib[:]) + if psib.IsEmpty() { + b.psib.AppendNull() + } else { + b.psib.Append(psib[:]) + } b.nb.AppendNonEmpty(span.Span.Name()) b.kb.AppendNonZero(int32(span.Span.Kind())) From 9f23c8c53bc8138c2f31a929407f65de82db3004 Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Mon, 11 Nov 2024 10:18:19 -0700 Subject: [PATCH 2/2] pkg/otel/traces/otlp: Handle null parentSpanID --- pkg/otel/traces/otlp/traces.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/otel/traces/otlp/traces.go b/pkg/otel/traces/otlp/traces.go index f7c7cb85..1cba3275 100644 --- a/pkg/otel/traces/otlp/traces.go +++ b/pkg/otel/traces/otlp/traces.go @@ -162,6 +162,10 @@ func TracesFrom(record arrow.Record, relatedData *RelatedData) (ptrace.Traces, e if parentSpanID != nil && len(parentSpanID) != 8 { return traces, werror.WrapWithContext(common.ErrInvalidSpanIDLength, map[string]interface{}{"parentSpanID": parentSpanID}) } + if parentSpanID == nil { + // parentSpanID can be null + parentSpanID = []byte{} + } name, err := arrowutils.StringFromRecord(record, traceIDs.Name, row) if err != nil { return traces, werror.Wrap(err)