MCPcopy
hub / github.com/prometheus/client_js / run

Function run

example/histogram-large-memory.js:8–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6// Create more metrics
7
8async function run() {
9 const labelNames = Array(10).map((_, idx) => `label_${idx}`);
10
11 const getRandomLabels = () =>
12 labelNames.reduce((acc, label) => {
13 return { ...acc, [label]: `value_${Math.random()}` };
14 }, {});
15
16 for (let i = 0; i < 100000; i++) {
17 const h = new Histogram({
18 name: `test_histogram_${i}`,
19 help: `Example of a histogram ${i}`,
20 buckets: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1],
21 labelNames,
22 });
23 h.observe(getRandomLabels(), Math.random());
24 }
25
26 await register.metrics();
27
28 global.gc();
29
30 v8.writeHeapSnapshot();
31}
32
33run();

Callers 1

Calls 3

getRandomLabelsFunction · 0.85
metricsMethod · 0.80
observeMethod · 0.65

Tested by

no test coverage detected