addMessage.js
854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* 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);