()
| 308 | * Get app context information from process |
| 309 | */ |
| 310 | export function getAppContext(): AppContext { |
| 311 | const app_memory = process.memoryUsage().rss; |
| 312 | // oxlint-disable-next-line sdk/no-unsafe-random-apis |
| 313 | const app_start_time = new Date(Date.now() - process.uptime() * 1000).toISOString(); |
| 314 | // https://nodejs.org/api/process.html#processavailablememory |
| 315 | const appContext: AppContext = { app_start_time, app_memory }; |
| 316 | |
| 317 | if (typeof (process as ProcessWithCurrentValues).availableMemory === 'function') { |
| 318 | const freeMemory = (process as ProcessWithCurrentValues).availableMemory?.(); |
| 319 | if (freeMemory != null) { |
| 320 | appContext.free_memory = freeMemory; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | return appContext; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Gets device information from os |
no test coverage detected