keymetrics/pm2-io-apm

View on GitHub
src/utils/miscellaneous.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { ServiceManager } from '../serviceManager'

export default class MiscUtils {
  static generateUUID (): string {
    return Math.random().toString(36).substr(2, 16)
  }

  static getValueFromDump (property, parentProperty?): number {
    if (!parentProperty) {
      parentProperty = 'handles'
    }
    const dump = ServiceManager.get('eventLoopService').inspector.dump()
    return dump[parentProperty].hasOwnProperty(property) ? dump[parentProperty][property].length : 0
  }
}