addMessage.js 854 Bytes
/**
 *  test addmessages
 */
const Sender = require('../index');

const sender = new Sender({
    host: 'influxd.yoho.cn',
    db: 'web-apm',
    measurement: 'api-duration',
    duration: 2000,
    records: 200
});

let num = 1;

let num2 = 1;

setInterval(() => {
    if (num > 10000) {
        console.log('1 done!');
        return;
    }
    sender.addMessage({
        tags: {
            reqid: num + '',
            route: 'test'
        },
        fields: {
            dasd: 'd123asda'
        }
    });
    num++;
}, Math.random() * 10);


setInterval(() => {
    if (num2 > 10000) {
        console.log('2 done!');
        return;
    }
    sender.addMessage({
        tags: {
            reqid: num2 + '',
            route: 'test2'
        },
        fields: {
            dasd: '12131'
        }
    });
    num2++;
}, Math.random() * 10);