-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathparam.js
50 lines (43 loc) · 1.25 KB
/
param.js
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
import { sleep } from 'k6';
import tracing from 'k6/x/tracing';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
export let options = {
vus: 1,
duration: "20m",
};
const endpoint = __ENV.ENDPOINT || "otel-collector:4317"
const client = new tracing.Client({
endpoint,
exporter: tracing.EXPORTER_OTLP,
tls: {
insecure: true,
}
});
export default function () {
let pushSizeTraces = randomIntBetween(2,3);
let pushSizeSpans = 0;
let t = [];
for (let i = 0; i < pushSizeTraces; i++) {
let c = randomIntBetween(5,10)
pushSizeSpans += c;
t.push({
random_service_name: false,
spans: {
count: c,
size: randomIntBetween(300,1000),
random_name: true,
fixed_attrs: {
"test": "test",
},
}
});
}
let gen = new tracing.ParameterizedGenerator(t)
let traces = gen.traces()
client.push(traces);
console.log(`Pushed ${pushSizeSpans} spans from ${pushSizeTraces} different traces. Here is a random traceID: ${t[Math.floor(Math.random() * t.length)].id}`);
sleep(15);
}
export function teardown() {
client.shutdown();
}