How to use the v8-profiler-next.takeSnapshot function in v8-profiler-next

To help you get started, we’ve selected a few v8-profiler-next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / auth0-instrumentation / lib / profiler.js View on Github external
Profiler.prototype.createSnapshot = function(reason) {
  const timestamp = moment().unix().toString();
  const path = `${this.heapshotDir}/${this.serviceName}-heap-${timestamp}.heapsnapshot`;
  const snapshot = v8Profiler.takeSnapshot();

  const done = (err, path) => {
    if (err) {
      return this.agent.logger.error(err);
    }
    this.report(path, reason);
  };

  process.send(JSON.stringify({ msg: 'pause_monitoring' }));

  snapshot.export()
    .pipe(fs.createWriteStream(path))
    .on('finish', () => {
      snapshot.delete();
      setTimeout(() => {
        process.send(JSON.stringify({ msg: 'resume_monitoring' }));

v8-profiler-next

node bindings for the v8 profiler

MIT
Latest version published 12 months ago

Package Health Score

55 / 100
Full package analysis