Add timer metrics to  {@link DistributedFileSystem#globStatus(Path)}
435554
public FileStatus[] globStatus(Path pathPattern) throws IOException {
    try (TimerContextWithLog context = new TimerContextWithLog(globStatusTimer.time(), "globStatus", pathPattern)) {
      FileStatus[] statuses = super.globStatus(pathPattern);
      context.setResult(statuses);
      return statuses;
    }
  }
879127
@SuppressWarnings("unchecked")
  public static void registerTopologyTimerEvents(Map<String, Object> conf,
                                                 String name, Duration interval,
                                                 Runnable task) {
    if (interval.isZero() || interval.isNegative()) {
      throw new IllegalArgumentException("Timer duration needs to be positive");
    }
    if (!conf.containsKey(Config.TOPOLOGY_TIMER_EVENTS)) {
      conf.put(Config.TOPOLOGY_TIMER_EVENTS, new HashMap<String, Pair<Duration, Runnable>>());
    }

    Map<String, Pair<Duration, Runnable>> timers
        = (Map<String, Pair<Duration, Runnable>>) conf.get(Config.TOPOLOGY_TIMER_EVENTS);

    if (timers.containsKey(name)) {
      throw new IllegalArgumentException("Timer with name " + name + " already exists");
    }
    timers.put(name, Pair.of(interval, task));
  }
742729
static FileStatus createFileStatus(String path, INode node) {
    // length is zero for directories
    return new FileStatus(node.isDirectory() ? 0 : node.computeContentSummary().getLength(),
        node.isDirectory(),
        node.isDirectory() ? 0 : ((INodeFile)node).getReplication(),
        node.isDirectory() ? 0 : ((INodeFile)node).getPreferredBlockSize(),
        node.getModificationTime(),
        node.getAccessTime(),
        node.getFsPermission(),
        node.getUserName(),
        node.getGroupName(),
        new Path(path));
  }
298679
@Override
    public Timer timer(String name) {
        return timer(new Metadata(name, MetricType.TIMER));
    }
681633
function(time, metrics) {
	var metricTypes = ['gauges', 'timer_data', 'timers', 'counters', 'sets'];

	metricTypes.forEach(function(type, i){
		var obj;

		for (var key in metrics[type]) {
			obj = aggregate[type](time, key, metrics[type][key]);

			insert(obj.db, obj.col, obj.data, function(err){
				if (err) console.log(err);
			});
		};
	});
}
324127
private Metric collectTimer(MetricName dropwizardMetric, Timer timer) {
    String metricName = DropWizardUtils.generateFullMetricName(dropwizardMetric.getKey(), "timer");
    String metricDescription =
        DropWizardUtils.generateFullMetricDescription(dropwizardMetric.getKey(), timer);
    final AbstractMap.SimpleImmutableEntry<List<LabelKey>, List<LabelValue>> labels =
        DropWizardUtils.generateLabels(dropwizardMetric);
    return collectSnapshotAndCount(
        metricName,
        metricDescription,
        labels.getKey(),
        labels.getValue(),
        NS_UNIT,
        timer.getSnapshot(),
        timer.getCount());
  }
444238
private List<HdfsStats> createFromScanResults(String cluster, String path,
      Scan scan, int maxCount, boolean checkPath, long starttime, long endtime)
      throws IOException {
    Map<HdfsStatsKey, HdfsStats> hdfsStats =
        new HashMap<HdfsStatsKey, HdfsStats>();
    ResultScanner scanner = null;
    Stopwatch timer = new Stopwatch().start();
    int rowCount = 0;
    long colCount = 0;
    long resultSize = 0;

    Table hdfsUsageTable = null;

    try {
      hdfsUsageTable = hbaseConnection
          .getTable(TableName.valueOf(HdfsConstants.HDFS_USAGE_TABLE));
      scanner = hdfsUsageTable.getScanner(scan);
      for (Result result : scanner) {
        if (result != null && !result.isEmpty()) {
          colCount += result.size();
          // TODO dogpiledays resultSize += result.getWritableSize();
          rowCount = populateHdfsStats(result, hdfsStats, checkPath, path,
              starttime, endtime, rowCount);
          // return if we've already hit the limit
          if (rowCount >= maxCount) {
            break;
          }
        }
      }

      timer.stop();
      LOG.info("In createFromScanResults For cluster " + cluster
          + " Fetched from hbase " + rowCount + " rows, " + colCount
          + " columns, " + resultSize + " bytes ( " + resultSize / (1024 * 1024)
          + ") MB, in total time of " + timer);
    } finally {
      try {
        if (scanner != null) {
          scanner.close();
        }
      } finally {
        if (hdfsUsageTable != null) {
          hdfsUsageTable.close();
        }
      }
    }

    List<HdfsStats> values = new ArrayList<HdfsStats>(hdfsStats.values());
    // sort so that timestamps are arranged in descending order
    Collections.sort(values);
    return values;
  }
880449
public void addJarsToIndex(final String folderPath) {

		logger.info("Starting adding jar files in " + folderPath);

		final CombinedTypeSolver typeSolver = new CombinedTypeSolver();
		typeSolver.add(new ReflectionTypeSolver());

		final AtomicLong count = new AtomicLong(0);

		try {
			Files.newDirectoryStream(Paths.get(folderPath), path -> path.toString().endsWith(".jar")).forEach((file) -> {
				try {
					typeSolver.add(new JarTypeSolver(new FileInputStream(file.toFile())));
					count.addAndGet(1L);

				} catch (IOException ex) {}
			}
260332
public RemoteIterator<LocatedFileStatus> listFiles(Path f, boolean recursive) throws FileNotFoundException, IOException {
    try (Closeable context = new TimerContextWithLog(this.listFilesTimer.time(), "listFiles", f, recursive)) {
      return super.listFiles(f, recursive);
    }
  }
228213
public static void refreshedFiles(String[] filePaths) {
    for (String filePath : filePaths) {
      IFile file = CommonServices.getFileSystem().getIFile(new File(filePath));
      if (file != null) {
        TypeSystem.refreshed(file);
      }
    }
  }
259946
public void registerMetrics(MetricsCollector metricsCollector) {
    SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(
        SystemConfig.HERON_SYSTEM_CONFIG);

    int interval = (int) systemConfig.getHeronMetricsExportInterval().getSeconds();

    metricsCollector.registerMetric("__jvm-gc-collection-time-ms", jvmGCTimeMs, interval);
    metricsCollector.registerMetric("__jvm-gc-collection-count", jvmGCCount, interval);

    metricsCollector.registerMetric("__jvm-gc-time-ms", jvmGCTimeMsPerGCType, interval);
    metricsCollector.registerMetric("__jvm-gc-count", jvmGCCountPerGCType, interval);

    metricsCollector.registerMetric("__jvm-uptime-secs", jvmUpTimeSecs, interval);

    metricsCollector.registerMetric("__jvm-thread-count", jvmThreadCount, interval);
    metricsCollector.registerMetric("__jvm-daemon-thread-count", jvmDaemonThreadCount, interval);
    metricsCollector.registerMetric("__jvm-process-cpu-time-nanos", processCPUTimeNs, interval);
    metricsCollector.registerMetric("__jvm-threads-cpu-time-nanos", threadsCPUTimeNs, interval);
    metricsCollector.registerMetric(
        "__jvm-other-threads-cpu-time-nanos", otherThreadsCPUTimeNs, interval);
    metricsCollector.registerMetric(
        "__jvm-threads-user-cpu-time-nanos", threadsUserCPUTimeNs, interval);
    metricsCollector.registerMetric(
        "__jvm-other-threads-user-cpu-time-nanos", otherThreadsUserCPUTimeNs, interval);
    metricsCollector.registerMetric("__jvm-process-cpu-load", processCPULoad, interval);

    metricsCollector.registerMetric("__jvm-fd-count", fdCount, interval);
    metricsCollector.registerMetric("__jvm-fd-limit", fdLimit, interval);

    metricsCollector.registerMetric("__jvm-memory-free-mb", jvmMemoryFreeMB, interval);
    metricsCollector.registerMetric("__jvm-memory-used-mb", jvmMemoryUsedMB, interval);
    metricsCollector.registerMetric("__jvm-memory-mb-total", jvmMemoryTotalMB, interval);
    metricsCollector.registerMetric("__jvm-memory-heap-mb-used", jvmMemoryHeapUsedMB, interval);
    metricsCollector.registerMetric(
        "__jvm-memory-heap-mb-committed", jvmMemoryHeapCommittedMB, interval);
    metricsCollector.registerMetric("__jvm-memory-heap-mb-max", jvmMemoryHeapMaxMB, interval);
    metricsCollector.registerMetric(
        "__jvm-memory-non-heap-mb-used", jvmMemoryNonHeapUsedMB, interval);
    metricsCollector.registerMetric(
        "__jvm-memory-non-heap-mb-committed", jvmMemoryNonHeapCommittedMB, interval);
    metricsCollector.registerMetric(
        "__jvm-memory-non-heap-mb-max", jvmMemoryNonHeapMaxMB, interval);

    metricsCollector.registerMetric(
        "__jvm-peak-usage", jvmPeakUsagePerMemoryPool, interval);
    metricsCollector.registerMetric(
        "__jvm-collection-usage", jvmCollectionUsagePerMemoryPool, interval);
    metricsCollector.registerMetric(
        "__jvm-estimated-usage", jvmEstimatedUsagePerMemoryPool, interval);

    metricsCollector.registerMetric("__jvm-buffer-pool", jvmBufferPoolMemoryUsage, interval);
  }
996270
private void addSinkTasks() {
    Runnable sinkTasks = new Runnable() {
      @Override
      public void run() {
        while (!metricsInSinkQueue.isEmpty()) {
          metricsSink.processRecord(metricsInSinkQueue.poll());
        }
      }
    };

    slaveLooper.addTasksOnWakeup(sinkTasks);
  }
94837
@Override
  public SortedMap<String, Timer> getTimers(MetricFilter filter) {
    return getSimplyNamedMetrics(Timer.class, Optional.of(filter));
  }
671070
function setupWatchers(path) {
    // We want to track the watchers now and return if we are already watching this folder
    if (watchingFolders[path]) { return; }

    watchingFolders[path] = fs.watch(path, getWatcher(path + "/"));
    watchingFolders[path].on('error', function() {  verifyWatches(); });
    var fileList = fs.readdirSync(path);
    var stats;
    for (var i = 0; i < fileList.length; i++) {
        try {
            stats = fs.statSync(path + "/" + fileList[i]);
        }
        catch (e) {
            continue;
        }
        if (isWatching(fileList[i])) {
            timeStamps[path + "/" + fileList[i]] = stats.mtime.getTime();
        } else {
            if (stats.isDirectory()) {
                if (fileList[i] === "node_modules") {
                    watchingFolders[path + "/" + fileList[i]] = true;
                    continue;
                }
                if (fileList[i] === "tns_modules") {
                    watchingFolders[path + "/" + fileList[i]] = true;
                    continue;
                }
                if (fileList[i] === "App_Resources") {
                    watchingFolders[path + "/" + fileList[i]] = true;
                    continue;
                }
                setupWatchers(path + "/" + fileList[i]);
            }
        }
    }
}
699145
private void addStatsdPlugin(String host, Integer port, String appName, Double sampleRate) {
    StatsdPlugin statsdPlugin;
    try {
      statsdPlugin = new StatsdPlugin(host, port, appName, sampleRate);
      InApplicationMonitor.getInstance().registerPlugin(statsdPlugin);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
739849
private void populateDatanodeMetrics(ArrayList<DatanodeDescriptor> live,
      ArrayList<DatanodeDescriptor> dead) {

    DatanodeStatus status = FSNamesystemDatanodeHelper.getDatanodeStats(fsNameSystem,
        live, dead);

    // populate metrics
    numLiveNodes.set(status.numLive);
    numLiveExcludedNodes.set(status.numLiveExcluded);
    numLiveDecommissioningInProgressNodes.set(status.numLiveDecommissioningInProgress);
    numLiveDecommissioned.set(status.numLiveDecommissioned);

    numDeadNodes.set(status.numDead);
    numDeadExcludedNodes.set(status.numDeadExcluded);
    numDeadDecommissioningNotCompletedNodes.set(status.numDeadDecommissioningNotCompleted);
    numDeadDecommissioned.set(status.numDeadDecommissioned);
  }
402512
MetricFamilySamples fromTimer(String dropwizardName, Timer timer) {
        return fromSnapshotAndCount(dropwizardName, timer.getSnapshot(), timer.getCount(),
                1.0D / TimeUnit.SECONDS.toNanos(1L), getHelpMessage(dropwizardName, timer));
    }