JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 796192
  • Score
    100M100P100Q187060F
  • License MIT

Structured instrumentation library

Package Exports

  • heimdalljs
  • heimdalljs/heimdall

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (heimdalljs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Example Usage

Simple

var heimdall = require('heimdall');

function BroccoliNodeSchema() {
  this.builds = 0;
}


heimdall.node('broccoli', function () {
  heimdall.node('node:babel', BroccoliNodeSchema, function (h) {
    h.builds++;

    heimdall.node('node:persistent-filter', BroccoliNodeSchema, function (h) {
      h.builds++;
    });

    heimdall.node('node:caching-writer', BroccoliNodeSchema, function (h) {
      h.builds++;
    });
  });
});
{
  "nodes": [{
    "id": 0,
    "name": "broccoli",
    "stats": {
      "cpu": {
        "self": 10,
      },
    },
    "children": {
      "start": [1],
      "end": [1],
    },
  }, {
    "id": 1,
    "name": "node:babel",
    "stats": {
      "builds": 1,
      "cpu": {
        "self": 20,
      },
    },
    "children": {
      "start": [2, 3],
      "end": [2, 3],
    },
  }, {
    "id": 2,
    "name": "node:persistent-filter",
    "stats": {
      "builds": 1,
      "cpu": {
        "self": 30,
      },
    },
  }, {
    "id": 3,
    "name": "node:caching-writer",
    "stats": {
      "builds": 1,
      "cpu": {
        "self": 40,
      },
    },
  }],
}

With Monitors

var heimdall = require('heimdall');
var fs = require('fs');

var origLstatSync = fs.lstatSync;
var origMkdirSync = fs.mkdirSync;

heimdall.registerMonitor('fs', function FSSchema() {
  this.lstatCount = 0;
  this.mkdirCount = 0;
});

fs.lstatSync = function () {
  heimdall.statsFor('fs').lstatCount++;
  return origLstatSync.apply(fs, arguments);
}

fs.mkdirSync = function () {
  heimdall.statsFor('fs').mkdirCount++;
  return origMkdirSync.apply(fs, arguments);
}


function BroccoliNodeSchema() {
  this.builds = 0;
}


heimdall.node('broccoli', function () {
  heimdall.node('node:babel', BroccoliNodeSchema, function (h) {
    h.builds++;

    heimdall.node('node:persistent-filter', BroccoliNodeSchema, function (h) {
      h.builds++;
      fs.mkdirSync('./tmp');
    });

    heimdall.node('node:caching-writer', BroccoliNodeSchema, function (h) {
      h.builds++;
      fs.lstatSync('./tmp');
    });
  });
});
{
  "nodes": [{
    "id": 0,
    "name": "broccoli",
    "stats": {
      "cpu": {
        "self": 10,
      },
      "fs": {
        lstatCount: 0,
        mkdirCount: 0,
      },
    },
    "children": {
      "start": [1],
      "end": [1],
    },
  }, {
    "id": 1,
    "name": "node:babel",
    "stats": {
      "builds": 1,
      "cpu": {
        "self": 20,
      },
      "fs": {
        lstatCount: 0,
        mkdirCount: 0,
      },
    },
    "children": {
      "start": [2, 3],
      "end": [2, 3],
    },
  }, {
    "id": 2,
    "name": "node:persistent-filter",
    "stats": {
      "builds": 1,
      "cpu": {
        "self": 30,
      },
      "fs": {
        lstatCount: 0,
        mkdirCount: 1,
      },
    },
  }, {
    "id": 3,
    "name": "node:caching-writer",
    "stats": {
      "builds": 1,
      "cpu": {
        "self": 40,
      },
      "fs": {
        lstatCount: 1,
        mkdirCount: 0,
      },
    },
  }],
}