UNPKG

@beincom/node-profile

Version:

``` npm install @beincom/node-profile # yarn add @beincom/node-profile ```

40 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HeapProfiler = void 0; const common_1 = require("@nestjs/common"); const pprof_1 = require("@datadog/pprof"); class HeapProfiler { constructor() { this.labels = {}; this.lastProfiledAt = new Date(); } getLabels() { return this.labels; } profile() { common_1.Logger.log('profile'); const profile = pprof_1.heap.profile(); const lastProfileStartedAt = this.lastProfiledAt; this.lastProfiledAt = new Date(); return { profile, startedAt: lastProfileStartedAt, stoppedAt: this.lastProfiledAt, }; } setLabels(labels) { this.labels = labels; } start(args) { common_1.Logger.log('start'); this.lastProfiledAt = new Date(); pprof_1.heap.start(args.samplingIntervalBytes, args.stackDepth); } stop() { common_1.Logger.log('stop'); pprof_1.heap.stop(); return null; } } exports.HeapProfiler = HeapProfiler; //# sourceMappingURL=heap-profiler.js.map