in exporter/collector/spandata.go [48:90]
func pdataSpanToOTSpanData(
span ptrace.Span,
resource pcommon.Resource,
is pcommon.InstrumentationScope,
) spanSnapshot {
sc := apitrace.SpanContextConfig{
TraceID: [16]byte(span.TraceID()),
SpanID: [8]byte(span.SpanID()),
}
parentSc := apitrace.SpanContextConfig{
TraceID: [16]byte(span.TraceID()),
SpanID: [8]byte(span.ParentSpanID()),
}
startTime := time.Unix(0, int64(span.StartTimestamp()))
endTime := time.Unix(0, int64(span.EndTimestamp()))
// TODO: Decide if ignoring the error is fine.
r, _ := sdkresource.New(
context.Background(),
sdkresource.WithAttributes(pdataAttributesToOTAttributes(pcommon.NewMap(), resource)...),
)
status := span.Status()
return spanSnapshot{
spanContext: apitrace.NewSpanContext(sc),
parent: apitrace.NewSpanContext(parentSc),
spanKind: pdataSpanKindToOTSpanKind(span.Kind()),
startTime: startTime,
endTime: endTime,
name: span.Name(),
attributes: pdataAttributesToOTAttributes(span.Attributes(), resource),
links: pdataLinksToOTLinks(span.Links()),
events: pdataEventsToOTMessageEvents(span.Events()),
droppedAttributes: int(span.DroppedAttributesCount()),
droppedMessageEvents: int(span.DroppedEventsCount()),
droppedLinks: int(span.DroppedLinksCount()),
resource: r,
instrumentationScope: instrumentationScopeLabels(is),
status: sdktrace.Status{
Code: pdataStatusCodeToOTCode(status.Code()),
Description: status.Message(),
},
}
}