@Override
  public MetricQueryResults queryMetrics(MetricsFilter filter) {
    List<MetricUpdate> metricUpdates;
    ImmutableList<MetricResult<Long>> counters = ImmutableList.of();
    ImmutableList<MetricResult<DistributionResult>> distributions = ImmutableList.of();
    ImmutableList<MetricResult<GaugeResult>> gauges = ImmutableList.of();
    ImmutableList<MetricResult<StringSetResult>> stringSets = ImmutableList.of();
    JobMetrics jobMetrics;
    try {
      jobMetrics = getJobMetrics();
    } catch (IOException e) {
      LOG.warn("Unable to query job metrics.\n");
      return MetricQueryResults.create(counters, distributions, gauges, stringSets);
    }
    metricUpdates = firstNonNull(jobMetrics.getMetrics(), Collections.emptyList());
    return populateMetricQueryResults(metricUpdates, filter);
  }
@Test
  public void testTemplateJobMetricsThrowsUsefulError() throws Exception {
    DataflowClient dataflowClient = mock(DataflowClient.class);
    DataflowMetrics metrics = new DataflowMetrics(new DataflowTemplateJob(), dataflowClient);

    assertThrows(
        "The result of template creation should not be used.",
        UnsupportedOperationException.class,
        () -> metrics.allMetrics());
    assertThrows(
        "The result of template creation should not be used.",
        UnsupportedOperationException.class,
        () -> metrics.queryMetrics(MetricsFilter.builder().build()));
  }