public static double getAvgMetricForTaskTypeAndMetricName(Map<String, Map<Integer, TonyTaskData>> taskMap,
      String taskType, String metricName) {
    double avgMetric = 0.0;
    double numMetrics = 0;
    if (taskMap.get(taskType) == null) {
      return -1.0d;
    }
    for (TonyTaskData taskData : taskMap.get(taskType).values()) {
      double avgMetricPerTask = 0.0;
      List<Metric> metrics = taskData.getMetrics();
      if (metrics == null) {
        continue;
      }
      for (Metric metric : metrics) {
        if (metric.getName().equals(metricName)) {
          if (metric.getValue() <= 0) {
            continue;
          }

          avgMetric += metric.getValue();
          numMetrics++;
        }
      }
    }

    return avgMetric / numMetrics;
  }
Returns the average metric value of all task of the specified type given metricName
Skips metrics collection for unavailable metric data
@param taskMap a map containing data for all tasks
@param taskType the task type
@param metricName the name of the metric to query
@return the average metric value of any task of the specified type
app/com/linkedin/drelephant/tony/util/TonyUtils.java