deserializeSpans method

AttributedSpans deserializeSpans(
  1. List spans, {
  2. AttributionDeserializeBuilder? deserializeBuilder,
})

反序列化AttributedSpans的数据

Implementation

AttributedSpans deserializeSpans(List<dynamic> spans,
    {AttributionDeserializeBuilder? deserializeBuilder}) {
  List<AttributionDeserializeBuilder?> builders = [
    deserializeBuilder,
    _customAttributionDeserializeBuilder,
    defaultAttributionDeserializeBuilder
  ];
  List<SpanMarker> markers = [];
  for (var marker in spans) {
    Attribution? attribution =
        _handleAttributionDeserialize(builders, marker);
    if (attribution == null) {
      throw '无法进行序列化 $marker';
    }
    SpanMarkerType type;
    if (marker[keySpanType] == SpanMarkerType.start.name) {
      type = SpanMarkerType.start;
    } else {
      type = SpanMarkerType.end;
    }
    markers.add(SpanMarker(
        attribution: attribution,
        offset: marker[keySpanOffset],
        markerType: type));
  }
  return AttributedSpans(attributions: markers);
}