zipkin-lens/src/zipkin/span-row.js
// Merges the data into a single span row, which is lacking presentation information
Merges the data into a single span row, which is lacking presentation information
Merges the data into a single span row which is lacking presentation information
function newSpanRow(spansToMerge) {
  const [first] = spansToMerge;
  const res = {
    spanId: first.id,
    serviceNames: [],
    annotations: [],
    tags: [],
    errorType: 'none',
  };
  let sharedTimestamp;
  let sharedDuration;
  spansToMerge.forEach((next) => {
    if (next.parentId) res.parentId = next.parentId;
    if (next.name && (!res.spanName || next.kind === 'SERVER')) {
      res.spanName = next.name; 
    }
    if (next.shared) { 
      if (!sharedTimestamp) sharedTimestamp = next.timestamp;
      if (!sharedDuration) sharedDuration = next.duration;
    } else {
      if (!res.timestamp && next.timestamp) res.timestamp = next.timestamp;
      if (!res.duration && next.duration) res.duration = next.duration;
    }
    const nextServiceName = getServiceName(next.localEndpoint);
    if (nextServiceName && (!res.serviceName || next.kind === 'SERVER')) {
      res.serviceName = nextServiceName; 
    }
    maybePushServiceName(res.serviceNames, nextServiceName);
    maybePushServiceName(res.serviceNames, getServiceName(next.remoteEndpoint));
    parseAnnotationRows(next).forEach(a => maybePushAnnotation(res.annotations, a));
    parseTagRows(next).forEach(t => maybePushTag(res.tags, t));
    res.errorType = getErrorType(next, res.errorType);
    if (next.debug) res.debug = true;
  });
  if (!res.timestamp && sharedTimestamp) res.timestamp = sharedTimestamp;
  if (!res.duration && sharedDuration) res.duration = sharedDuration;
  res.serviceNames.sort();
  res.annotations.sort((a, b) => a.timestamp - b.timestamp);
  return res;
}
function newSpanRow ( spansToMerge ) { const [ first ] = spansToMerge ; const res = { spanId : first . id , serviceNames : [ ] , annotations : [ ] , tags : [ ] , errorType : 'none' , } ; let sharedTimestamp ; let sharedDuration ; spansToMerge . forEach ( ( next ) => { if ( next . parentId ) res . parentId = next . parentId ; if ( next . name && ( ! res . spanName || next . kind === 'SERVER' ) ) { res . spanName = next . name ; } if ( next . shared ) { if ( ! sharedTimestamp ) sharedTimestamp = next . timestamp ; if ( ! sharedDuration ) sharedDuration = next . duration ; } else { if ( ! res . timestamp && next . timestamp ) res . timestamp = next . timestamp ; if ( ! res . duration && next . duration ) res . duration = next . duration ; } const nextServiceName = getServiceName ( next . localEndpoint ) ; if ( nextServiceName && ( ! res . serviceName || next . kind === 'SERVER' ) ) { res . serviceName = nextServiceName ; } maybePushServiceName ( res . serviceNames , nextServiceName ) ; maybePushServiceName ( res . serviceNames , getServiceName ( next . remoteEndpoint ) ) ; parseAnnotationRows ( next ) . forEach ( a => maybePushAnnotation ( res . annotations , a ) ) ; parseTagRows ( next ) . forEach ( t => maybePushTag ( res . tags , t ) ) ; res . errorType = getErrorType ( next , res . errorType ) ; if ( next . debug ) res . debug = true ; } ) ; if ( ! res . timestamp && sharedTimestamp ) res . timestamp = sharedTimestamp ; if ( ! res . duration && sharedDuration ) res . duration = sharedDuration ; res . serviceNames . sort ( ) ; res . annotations . sort ( ( a , b ) => a . timestamp - b . timestamp ) ; return res ; }
Merges the data into a single span row, which is lacking presentation information
Merges the data into a single span row which is lacking presentation information
// prefer the server's span name // save off any shared timestamp, it is our second choice // prefer the server's service name // timestamp is used to derive positional data later // duration is used for deriving data, and also for the zoom function