<commit_before>'use strict';

var _ = require('lodash');
var vamp = require('vamp-node-client');

var api = new vamp.Api();
var metrics = new vamp.Metrics(api);

var period = 5;  // seconds
var window = 30; // seconds

var process = function() {
  api.gateways(function (gateways) {
      _.forEach(gateways, function(gateway) {
          metrics.average({ ft: gateway.lookup_name }, 'Tt', window, function(total, rate, responseTime) {
              api.event(['gateways:' + gateway.name, 'metrics:rate'], rate);
              api.event(['gateways:' + gateway.name, 'metrics:responseTime'], responseTime);
          });
      });
  });
};

process();

setInterval(process, period * 1000);
<commit_msg>route metrics, #746<commit_after>'use strict';

var _ = require('lodash');
var vamp = require('vamp-node-client');

var api = new vamp.Api();
var metrics = new vamp.Metrics(api);

var period = 5;  // seconds
var window = 30; // seconds

var process = function() {
  api.gateways(function (gateways) {
      _.forEach(gateways, function(gateway) {
          metrics.average({ ft: gateway.lookup_name }, 'Tt', window, function(total, rate, responseTime) {
              api.event(['gateways:' + gateway.name, 'metrics:rate'], rate);
              api.event(['gateways:' + gateway.name, 'metrics:responseTime'], responseTime);
          });

          _.forOwn(gateway.routes, function (route, routeName) {
            metrics.average({ ft: route.lookup_name }, 'Tt', window, function(total, rate, responseTime) {
                api.event(['gateways:' + gateway.name, 'routes:' + routeName, 'metrics:rate'], rate);
                api.event(['gateways:' + gateway.name, 'routes:' + routeName, 'metrics:responseTime'], responseTime);
            });
          });
      });
  });
};

process();

setInterval(process, period * 1000);

{'fraction_non_alphanumeric': 0.17149098853085745, 'fraction_numerical': 0.009284543965046422, 'mean_word_length': 3.173120728929385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1086125', 'n_tokens_mistral': 568, 'n_tokens_neox': 539, 'n_words': 126}