Skip to content

Commit

Permalink
[ObsUX][Synthtrace] Remove pidusage for logging cpu usage (elastic#…
Browse files Browse the repository at this point in the history
…204043)

## Summary

Removes `pidusage` in favour of just getting cpu usage stats from
`node:process` for logging purposes. Other than that, not sure the point
of logging this, but keeping it in case it serves some purpose.

Closes elastic#203983 

## How to test

Not sure, make sure CI doesn't break or something from its removal,
given it is only used for logging.
  • Loading branch information
Bluefinger authored Dec 13, 2024
1 parent 20b7e23 commit 5791d36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,6 @@
"@types/pbf": "3.0.2",
"@types/pdfmake": "^0.2.2",
"@types/picomatch": "^2.3.0",
"@types/pidusage": "^2.0.2",
"@types/pixelmatch": "^5.2.4",
"@types/pngjs": "^6.0.5",
"@types/prop-types": "^15.7.5",
Expand Down Expand Up @@ -1807,7 +1806,6 @@
"p-reflect": "2.1.0",
"peggy": "^1.2.0",
"picomatch": "^2.3.1",
"pidusage": "^3.0.2",
"pirates": "^4.0.1",
"piscina": "^3.2.0",
"pixelmatch": "^5.3.0",
Expand Down
11 changes: 8 additions & 3 deletions packages/kbn-apm-synthtrace/src/cli/utils/synthtrace_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import { timerange } from '@kbn/apm-synthtrace-client';
import { castArray } from 'lodash';
import pidusage from 'pidusage';
import { memoryUsage } from 'process';
import { parentPort, workerData } from 'worker_threads';
import { getApmEsClient } from './get_apm_es_client';
Expand Down Expand Up @@ -123,10 +122,16 @@ async function start() {
return Math.round(value / 1024 ** 2).toString() + 'mb';
}

let cpuUsage = process.cpuUsage();

setInterval(async () => {
const stats = await pidusage(process.pid);
cpuUsage = process.cpuUsage(cpuUsage);
const mem = memoryUsage();
logger.info(`cpu: ${stats.cpu}, memory: ${mb(mem.heapUsed)}/${mb(mem.heapTotal)}`);
logger.info(
`cpu time: (user: ${cpuUsage.user}µs, sys: ${cpuUsage.system}µs), memory: ${mb(
mem.heapUsed
)}/${mb(mem.heapTotal)}`
);
}, 5000);

await logger.perf('index_scenario', async () => {
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12097,11 +12097,6 @@
resolved "https://registry.yarnpkg.com/@types/picomatch/-/picomatch-2.3.0.tgz#75db5e75a713c5a83d5b76780c3da84a82806003"
integrity sha512-O397rnSS9iQI4OirieAtsDqvCj4+3eY1J+EPdNTKuHuRWIfUoGyzX294o8C4KJYaLqgSrd2o60c5EqCU8Zv02g==

"@types/pidusage@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@types/pidusage/-/pidusage-2.0.2.tgz#3f8c4b19ba7ea438a733d093661e92b60e5f88ee"
integrity sha512-lHgpGZjXDfjggZDLkgp4zQTYkvXq4S7RxjBjrDcPe1MBU72hESWxubutx8+AM4QkJdRxAhrQyxSA6pzHKJKlsQ==

"@types/pixelmatch@^5.2.4":
version "5.2.4"
resolved "https://registry.yarnpkg.com/@types/pixelmatch/-/pixelmatch-5.2.4.tgz#ca145cc5ede1388c71c68edf2d1f5190e5ddd0f6"
Expand Down Expand Up @@ -26284,13 +26279,6 @@ picomatch@^4.0.2:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab"
integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==

pidusage@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/pidusage/-/pidusage-3.0.2.tgz#6faa5402b2530b3af2cf93d13bcf202889724a53"
integrity sha512-g0VU+y08pKw5M8EZ2rIGiEBaB8wrQMjYGFfW2QVIfyT8V+fq8YFLkvlz4bz5ljvFDJYNFCWT3PWqcRr2FKO81w==
dependencies:
safe-buffer "^5.2.1"

pify@^2.0.0, pify@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
Expand Down

0 comments on commit 5791d36

Please sign in to comment.