@nxtedition/lib 19.10.5 → 19.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app.js +25 -22
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -438,7 +438,24 @@ export function makeApp(appConfig, onTerminate) {
438
438
  timestamp: Date.now(),
439
439
  })),
440
440
  rx.auditTime(1e3),
441
- rx.filter(Boolean),
441
+ rx.withLatestFrom(
442
+ rxjs.timer(0, 1e3).pipe(
443
+ rx.map(() => performance.eventLoopUtilization?.()),
444
+ rx.pairwise(),
445
+ rx.map(([elu1, elu2]) => ({
446
+ ds: ds?.stats,
447
+ couch: couch?.stats,
448
+ lag: toobusy?.lag(),
449
+ memory: process.memoryUsage(),
450
+ utilization: performance.eventLoopUtilization?.(elu2, elu1),
451
+ heap: v8.getHeapStatistics(),
452
+ })),
453
+ ),
454
+ ),
455
+ rx.map(([serviceStats, appStats]) => ({
456
+ ...appStats,
457
+ [serviceName]: serviceStats,
458
+ })),
442
459
  rx.retryWhen((err$) =>
443
460
  err$.pipe(
444
461
  rx.tap((err) => logger.error({ err }, 'monitor.stats')),
@@ -452,27 +469,13 @@ export function makeApp(appConfig, onTerminate) {
452
469
 
453
470
  monitorProviders.stats$ = stats$
454
471
 
455
- let elu1 = performance.eventLoopUtilization?.()
456
- const subscription = stats$.pipe(rx.auditTime(10e3)).subscribe((stats) => {
457
- if (process.env.NODE_ENV === 'production') {
458
- const elu2 = performance.eventLoopUtilization?.()
459
- logger.debug(
460
- {
461
- ds: ds?.stats,
462
- couch: couch?.stats,
463
- lag: toobusy?.lag(),
464
- memory: process.memoryUsage(),
465
- utilization: performance.eventLoopUtilization?.(elu2, elu1),
466
- heap: v8.getHeapStatistics(),
467
- [serviceName]: stats,
468
- },
469
- 'STATS',
470
- )
471
- elu1 = elu2
472
- }
473
- })
474
-
475
- appDestroyers.unshift(subscription)
472
+ if (process.env.NODE_ENV === 'production') {
473
+ appDestroyers.unshift(
474
+ stats$.pipe(rx.auditTime(10e3)).subscribe((stats) => {
475
+ logger.debug(stats, 'STATS')
476
+ }),
477
+ )
478
+ }
476
479
  }
477
480
 
478
481
  let status$
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.10.5",
3
+ "version": "19.11.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",