Skip to content

Commit

Permalink
fix(host-metrics): fallback to process.memoryUsage() (open-telemetry#…
Browse files Browse the repository at this point in the history
…1471)

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 25, 2023
1 parent 47122f3 commit 4d11d61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/opentelemetry-host-metrics/src/stats/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,10 @@ export function getMemoryData(): MemoryData {
* including all C++ and JavaScript objects and code.
*/
export function getProcessMemoryData(): number {
return process.memoryUsage.rss();
// `process.memoryUsage.rss` is a faster alternative introduced in v14.18.0.
// Prefer it if available.
if (process.memoryUsage.rss) {
return process.memoryUsage.rss();
}
return process.memoryUsage().rss;
}

0 comments on commit 4d11d61

Please sign in to comment.