packages/core/lib/capture.js
function captureFunc(name, fcn, parent) {
  validate(name, fcn);

  var current, executeFcn;

  var parentSeg = contextUtils.resolveSegment(parent);

  if (!parentSeg) {
    logger.getLogger().warn('Failed to capture function.');
    return fcn();
  }

  current = parentSeg.addNewSubsegment(name);
  executeFcn = captureFcn(fcn, current);

  try {
    executeFcn(current);
    current.close();
  } catch (e) {
    current.close(e);
    throw(e);
  }
}
function captureFunc(name, fcn, parent) {
  validate(name, fcn);

  var current, executeFcn;

  var parentSeg = contextUtils.resolveSegment(parent);

  if (!parentSeg) {
    logger.getLogger().warn('Failed to capture function.');
    return fcn();
  }

  current = parentSeg.addNewSubsegment(name);
  executeFcn = captureFcn(fcn, current);

  try {
    executeFcn(current);
    current.close();
  } catch (e) {
    current.close(e);
    throw(e);
  }
}
function captureFunc ( name , fcn , parent ) { validate ( name , fcn ) ; var current , executeFcn ; var parentSeg = contextUtils . resolveSegment ( parent ) ; if ( ! parentSeg ) { logger . getLogger ( ) . warn ( 'Failed to capture function.' ) ; return fcn ( ) ; } current = parentSeg . addNewSubsegment ( name ) ; executeFcn = captureFcn ( fcn , current ) ; try { executeFcn ( current ) ; current . close ( ) ; } catch ( e ) { current . close ( e ) ; throw ( e ) ; } }
Wrap to automatically capture information for the segment.
@param {string} name - The name of the new subsegment.
@param {function} fcn - The function context to wrap. Can take a single 'subsegment' argument.
@param {Segment|Subsegment} [parent] - The parent for the new subsegment, for manual mode.
@alias module:capture.captureFunc
Wrap to automatically capture information for the segment .