How to use the heimdalljs.statsFor function in heimdalljs

To help you get started, we’ve selected a few heimdalljs 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 ember-cli / ember-cli / lib / models / addon.js View on Github external
cacheKeyForTree(treeType) {
    let methodsToValidate = methodsForTreeType(treeType);
    let cacheKeyStats = heimdall.statsFor('cache-key-for-tree');

    // determine if treeFor* (or other methods for tree type) overrides for the given tree
    let modifiedMethods = methodsToValidate.filter(methodName => this[methodName] !== addonProto[methodName]);

    if (modifiedMethods.length) {
      cacheKeyStats.modifiedMethods++;
      cacheKeyLogger.info(`Opting out due to: modified methods: ${modifiedMethods.join(', ')}`);
      return null; // uncacheable
    }

    // determine if treeForMethods overrides for given tree
    if (this.treeForMethods[treeType] !== DEFAULT_TREE_FOR_METHODS[treeType]) {
      cacheKeyStats.treeForMethodsOverride++;
      cacheKeyLogger.info('Opting out due to: treeForMethods override');
      return null; // uncacheable
    }
github stefanpenner / async-disk-cache / index.js View on Github external
obj[name] = function() {
    const stats = heimdall.statsFor('async-disk-cache');
    const metrics = stats[name] = stats[name] || new Metric();

    metrics.start();

    let result;
    let didError = true;

    try {
      result = fn.apply(this, arguments);
      didError = false;
    } finally {
      if (didError) {
        metrics.stop();
      }
    }
github ember-cli / ember-cli / lib / models / addon.js View on Github external
getItem(key) {
    let addonTreeCacheStats = heimdall.statsFor('addon-tree-cache');
    let cachedValue = this.__cache[key];

    if (cachedValue) {
      addonTreeCacheStats.hits++;
      treeCacheLogger.info(`Cache Hit: ${key}`);
      return cachedValue;
    } else {
      addonTreeCacheStats.misses++;
      treeCacheLogger.info(`Cache Miss: ${key}`);
      return null;
    }
  },
github ember-cli / ember-cli / lib / models / addon.js View on Github external
setItem(key, value) {
    let hasValue = !!value;
    heimdall.statsFor('addon-tree-cache').adds++;
    treeCacheLogger.info(`Cache Add: ${key} - ${hasValue}`);
    this.__cache[key] = value;
  },

heimdalljs

Structured instrumentation library

MIT
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis