packages/collector/src/agentConnection.js
function sendRequestsSync(requests) {
  // only try to require optional dependency netlinkwrapper once
  if (!netLinkHasBeenRequired) {
    netLinkHasBeenRequired = true;
    try {
      netLink = require('netlinkwrapper')();
    } catch (requireNetlinkError) {
      logger.warn(
        'Failed to require optional dependency netlinkwrapper, uncaught exception will not be reported to Instana.'
      );
    }
  }
  if (!netLink) {
    return;
  }

  var port = agentOpts.port;
  if (typeof port !== 'number') {
    try {
      port = parseInt(port, 10);
    } catch (nonNumericPortError) {
      logger.warn('Detected non-numeric port configuration value %s, uncaught exception will not be reported.', port);
      return;
    }
  }

  try {
    netLink.connect(port, agentOpts.host);
    netLink.blocking(false);
    requests.forEach(function(request) {
      sendHttpPostRequestSync(port, request.path, request.data);
    });
  } catch (netLinkError) {
    logger.warn('Failed to report uncaught exception due to network error.', { error: netLinkError });
  } finally {
    try {
      netLink.disconnect();
    } catch (ignoreDisconnectError) {
      logger.debug('Failed to disconnect after trying to report uncaught exception.');
    }
  }
}
function sendRequestsSync(requests) {
  // only try to require optional dependency netlinkwrapper once
  if (!netLinkHasBeenRequired) {
    netLinkHasBeenRequired = true;
    try {
      netLink = require('netlinkwrapper')();
    } catch (requireNetlinkError) {
      logger.warn(
        'Failed to require optional dependency netlinkwrapper, uncaught exception will not be reported to Instana.'
      );
    }
  }
  if (!netLink) {
    return;
  }

  var port = agentOpts.port;
  if (typeof port !== 'number') {
    try {
      port = parseInt(port, 10);
    } catch (nonNumericPortError) {
      logger.warn('Detected non-numeric port configuration value %s, uncaught exception will not be reported.', port);
      return;
    }
  }

  try {
    netLink.connect(port, agentOpts.host);
    netLink.blocking(false);
    requests.forEach(function(request) {
      sendHttpPostRequestSync(port, request.path, request.data);
    });
  } catch (netLinkError) {
    logger.warn('Failed to report uncaught exception due to network error.', { error: netLinkError });
  } finally {
    try {
      netLink.disconnect();
    } catch (ignoreDisconnectError) {
      logger.debug('Failed to disconnect after trying to report uncaught exception.');
    }
  }
}
function sendRequestsSync ( requests ) { // only try to require optional dependency netlinkwrapper once if ( ! netLinkHasBeenRequired ) { netLinkHasBeenRequired = true ; try { netLink = require ( 'netlinkwrapper' ) ( ) ; } catch ( requireNetlinkError ) { logger . warn ( 'Failed to require optional dependency netlinkwrapper, uncaught exception will not be reported to Instana.' ) ; } } if ( ! netLink ) { return ; } var port = agentOpts . port ; if ( typeof port !== 'number' ) { try { port = parseInt ( port , 10 ) ; } catch ( nonNumericPortError ) { logger . warn ( 'Detected non-numeric port configuration value %s, uncaught exception will not be reported.' , port ) ; return ; } } try { netLink . connect ( port , agentOpts . host ) ; netLink . blocking ( false ) ; requests . forEach ( function ( request ) { sendHttpPostRequestSync ( port , request . path , request . data ) ; } ) ; } catch ( netLinkError ) { logger . warn ( 'Failed to report uncaught exception due to network error.' , { error : netLinkError } ) ; } finally { try { netLink . disconnect ( ) ; } catch ( ignoreDisconnectError ) { logger . debug ( 'Failed to disconnect after trying to report uncaught exception.' ) ; } } }
Sends multiple HTTP POST requests to the agent. This function is synchronous, that is, it blocks the event loop!

YOU MUST NOT USE THIS FUNCTION, except for the one use case where it is actually required to block the event loop
(reporting an uncaught exception tot the agent in the process.on('uncaughtException') handler).
Sends multiple HTTP POST requests to the agent . This function is synchronous that is it blocks the event loop!