packages/core/lib/segment_emitter.js
function send(segment) {
    var client = this.socket;
    var formatted = segment.format();
    var data = PROTOCOL_HEADER + PROTOCOL_DELIMITER + formatted;
    var message = new Buffer(data);

    var short = '{"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}';
    var type = segment.type === 'subsegment' ? 'Subsegment' : 'Segment';

    client.send(message, 0, message.length, this.daemonConfig.udp_port, this.daemonConfig.udp_ip, function(err) {
      if (err) {
        if (err.code === 'EMSGSIZE')
          logger.getLogger().error(type + ' too large to send: ' + short + ' (' + message.length + ' bytes).');
        else
          logger.getLogger().error('Error occured sending segment: ', err);
      } else {
        logger.getLogger().debug(type + ' sent: {"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}');
        logger.getLogger().debug('UDP message sent: ' + segment);
      }
    });
  }
function send(segment) {
    var client = this.socket;
    var formatted = segment.format();
    var data = PROTOCOL_HEADER + PROTOCOL_DELIMITER + formatted;
    var message = new Buffer(data);

    var short = '{"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}';
    var type = segment.type === 'subsegment' ? 'Subsegment' : 'Segment';

    client.send(message, 0, message.length, this.daemonConfig.udp_port, this.daemonConfig.udp_ip, function(err) {
      if (err) {
        if (err.code === 'EMSGSIZE')
          logger.getLogger().error(type + ' too large to send: ' + short + ' (' + message.length + ' bytes).');
        else
          logger.getLogger().error('Error occured sending segment: ', err);
      } else {
        logger.getLogger().debug(type + ' sent: {"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}');
        logger.getLogger().debug('UDP message sent: ' + segment);
      }
    });
  }
function send ( segment ) { var client = this . socket ; var formatted = segment . format ( ) ; var data = PROTOCOL_HEADER + PROTOCOL_DELIMITER + formatted ; var message = new Buffer ( data ) ; var short = '{"trace_id:"' + segment . trace_id + '","id":"' + segment . id + '"}' ; var type = segment . type === 'subsegment' ? 'Subsegment' : 'Segment' ; client . send ( message , 0 , message . length , this . daemonConfig . udp_port , this . daemonConfig . udp_ip , function ( err ) { if ( err ) { if ( err . code === 'EMSGSIZE' ) logger . getLogger ( ) . error ( type + ' too large to send: ' + short + ' (' + message . length + ' bytes).' ) ; else logger . getLogger ( ) . error ( 'Error occured sending segment: ' , err ) ; } else { logger . getLogger ( ) . debug ( type + ' sent: {"trace_id:"' + segment . trace_id + '","id":"' + segment . id + '"}' ) ; logger . getLogger ( ) . debug ( 'UDP message sent: ' + segment ) ; } } ) ; }
Creates a UDP socket connection and send the formatted segment.
@param {Segment} segment - The segment to send to the daemon.
Creates a UDP socket connection and send the formatted segment .