Y

yoho-apm-agent

241ca68c 0.0.2 · by htoooth

influx-batch-sender

buffer message and send them in a bulk.

useage

const Sender = require('../index');

const sender = new Sender({
    host: 'influxd.yoho.cn',
    db: 'web-apm',
    measurement: 'api-duration',
    duration: 2000,  // 多长时间发送一次,默认值是 2000ms
    records: 200,  // 累积多少条消息发送一次,默认值是100
    immediate: true // 是否立刻发送消息,设置为 true 会忽略 records 设置,默认值是 false
    path: "/url", // 重新设置发送消息的路径,默认值是 /write
});

setInterval(() => {
    sender.addMessage({
        tags: {
            reqid: 'sdasda'+Math.random(),
            route: 'test'
        },
        fields: {
            dasd: "d123asda"
        }
    });
}, Math.random() * 100)