From a116deb3fe6a1d7aa60b57c4a39a65c16d33d44c Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Tue, 19 Nov 2024 17:32:04 +0100 Subject: [PATCH] pkg/otel/trace/arrow: Set parentSpanID NULL if empty bytes (#273) Fixes #272 --- pkg/otel/traces/arrow/traces.go | 6 +++++- pkg/otel/traces/otlp/traces.go | 4 ++++ 2 files changed, 9 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())) 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)