You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next.js application that calculates Prime numbers ( client side, CPU heavy )
Node.js "puppeteer" application that navigates to the UI, and generates 10000 prime numbers
constpuppeteer=require('puppeteer');(async()=>{try{constbrowser=awaitpuppeteer.launch({headless: true,// Keep as true});constpage=awaitbrowser.newPage();awaitpage.goto('http://127.0.0.1:3001');awaitpage.type('#limit','1000000');// generate prime numbers buttonawaitpage.click('.bg-blue-500.text-white.p-2.rounded');// etc}catch(error){console.error('An error occurred:',error);}})();
The idea of this example is to generate a "CPU Leak" / memory leak on the client side
The problem with this is:
cardamon can only record PID's of processes it spawns
Puppeteer spawns chromium ( browser) not as a child process but as a detached process
This means after recording the CPU usage of our node.js program, we get a CPU usage of 0
Proposed changed:
Add the ability to send Process ID's to cardamon after it's started
One implementation of doing this would be as follows:
Create a http-server via cardamon
Await a post request with process ID's to start the scenario
Example node.js code:
constpuppeteer=require('puppeteer');constrequest=require('request');(async()=>{try{console.log('Starting puppeteer');constbrowser=awaitpuppeteer.launch({headless: true,// Keep as true});request.post('http://127.0.0.1:XX/api/pid',{json: {name: 'browser_click',pid: browser.process().pid}},function(error,response,body){if(!error&&response.statusCode==200){console.log(body);}});constpage=awaitbrowser.newPage();awaitpage.goto('http://127.0.0.1:3001');awaitpage.type('#limit','1000000');// generate prime numbers buttonawaitpage.click('.bg-blue-500.text-white.p-2.rounded');// This will timeout at 30s awaitpage.waitForNavigation({waitUntil: 'networkidle0'});console.log('Actions completed successfully');awaitbrowser.close();}catch(error){console.error('An error occurred:',error);}})();
Example cardamon.toml config:
[[processes]]
name = "pupp"up = "node puppeteer.js"
[processes.redirect]
to = "parent"
[processes.process]
type = "baremetal"
[process.pid]
hang = truename = "browser_click"
The idea here is to hang the starting of logging / metrics until the "pupp" process has sent a PID
The text was updated successfully, but these errors were encountered:
seal
changed the title
Add ability to add processes not started by cardamon
Add ability to monitor processes not started by cardamon
Jul 5, 2024
Example used:
The idea of this example is to generate a "CPU Leak" / memory leak on the client side
The problem with this is:
This means after recording the CPU usage of our node.js program, we get a CPU usage of 0
Proposed changed:
One implementation of doing this would be as follows:
Example node.js code:
Example cardamon.toml config:
The idea here is to hang the starting of logging / metrics until the "pupp" process has sent a PID
The text was updated successfully, but these errors were encountered: