packages/collector/src/agentConnection.js
function sendHttpPostRequestSync(port, path, data) {
  logger.debug({ payload: data }, 'Sending payload synchronously to %s', path);
  try {
    var payload = JSON.stringify(data);
    var payloadLength = buffer.fromString(payload, 'utf8').length;
  } catch (payloadSerializationError) {
    logger.warn('Could not serialize payload, uncaught exception will not be reported.', {
      error: payloadSerializationError
    });
    return;
  }

  // prettier-ignore
  netLink.write(
    'POST ' + path + ' HTTP/1.1\u000d\u000a' +
    'Host: ' + agentOpts.host + '\u000d\u000a' +
    'Content-Type: application/json; charset=UTF-8\u000d\u000a' +
    'Content-Length: ' + payloadLength + '\u000d\u000a' +
    '\u000d\u000a' + // extra CRLF before body
    payload
  );
}
function sendHttpPostRequestSync(port, path, data) {
  logger.debug({ payload: data }, 'Sending payload synchronously to %s', path);
  try {
    var payload = JSON.stringify(data);
    var payloadLength = buffer.fromString(payload, 'utf8').length;
  } catch (payloadSerializationError) {
    logger.warn('Could not serialize payload, uncaught exception will not be reported.', {
      error: payloadSerializationError
    });
    return;
  }

  // prettier-ignore
  netLink.write(
    'POST ' + path + ' HTTP/1.1\u000d\u000a' +
    'Host: ' + agentOpts.host + '\u000d\u000a' +
    'Content-Type: application/json; charset=UTF-8\u000d\u000a' +
    'Content-Length: ' + payloadLength + '\u000d\u000a' +
    '\u000d\u000a' + // extra CRLF before body
    payload
  );
}
function sendHttpPostRequestSync ( port , path , data ) { logger . debug ( { payload : data } , 'Sending payload synchronously to %s' , path ) ; try { var payload = JSON . stringify ( data ) ; var payloadLength = buffer . fromString ( payload , 'utf8' ) . length ; } catch ( payloadSerializationError ) { logger . warn ( 'Could not serialize payload, uncaught exception will not be reported.' , { error : payloadSerializationError } ) ; return ; } // prettier-ignore netLink . write ( 'POST ' + path + ' HTTP/1.1\u000d\u000a' + 'Host: ' + agentOpts . host + '\u000d\u000a' + 'Content-Type: application/json; charset=UTF-8\u000d\u000a' + 'Content-Length: ' + payloadLength + '\u000d\u000a' + '\u000d\u000a' + // extra CRLF before body payload ) ; }
Sends a single, synchronous HTTP POST request 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 a single synchronous HTTP POST request to the agent . This function is synchronous that is it blocks the event loop!