Skip to content

Commit

Permalink
pkg/otel/trace/arrow: Set parentSpanID NULL if empty bytes (#273)
Browse files Browse the repository at this point in the history
Fixes #272
  • Loading branch information
metalmatze authored Nov 19, 2024
1 parent 817b9e4 commit a116deb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/otel/traces/arrow/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand Down
4 changes: 4 additions & 0 deletions pkg/otel/traces/otlp/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a116deb

Please sign in to comment.