org.apache.hadoop.metrics2.MetricsRecord Java Examples

The following examples show how to use org.apache.hadoop.metrics2.MetricsRecord. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggingSink.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
    // we could wait until flush, but this is a really lightweight process, so we just write
    // them
    // as soon as we get them
    if (!LOG.isDebugEnabled()) {
        return;
    }
    LOG.debug("Found record:" + record.name());
    for (AbstractMetric metric : record.metrics()) {
        // just print the metric we care about
        if (metric.name().startsWith(TracingUtils.METRIC_SOURCE_KEY)) {
            LOG.debug("\t metric:" + metric);
        }
    }
}
 
Example #2
Source File: GangliaSink30.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@InterfaceAudience.Private
public void appendPrefix(MetricsRecord record, StringBuilder sb) {
  String contextName = record.context();
  Collection<MetricsTag> tags = record.tags();
  if (useTagsMap.containsKey(contextName)) {
    Set<String> useTags = useTagsMap.get(contextName);
    for (MetricsTag t : tags) {
      if (useTags == null || useTags.contains(t.name())) {

        // the context is always skipped here because it is always added
        
        // the hostname is always skipped to avoid case-mismatches 
        // from different DNSes.

        if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) {
          sb.append('.').append(t.name()).append('=').append(t.value());
        }
      }
    }
  }          
}
 
Example #3
Source File: HadoopTimelineMetricsSink.java    From ambari-metrics with Apache License 2.0 6 votes vote down vote up
private void emitContainerMetrics(MetricsRecord record) {

    ContainerMetric containerMetric = new ContainerMetric();
    containerMetric.setHostName(hostName);

    for (MetricsTag tag : record.tags()) {
      if (tag.name().equals("ContainerResource")) {
        containerMetric.setContainerId(tag.value());
      }
    }

    parseContainerMetrics(record, containerMetric);
    List<ContainerMetric> list = new ArrayList<>();
    list.add(containerMetric);
    String jsonData = null;
    try {
      jsonData = mapper.writeValueAsString(list);
    } catch (IOException e) {
      LOG.error("Unable to parse container metrics ", e);
    }
    if (jsonData != null) {
      String collectorHost = getCurrentCollectorHost();
      containerMetricsUri = constructContainerMetricUri(protocol, collectorHost, port);
      emitMetricsJson(containerMetricsUri, jsonData);
    }
  }
 
Example #4
Source File: HadoopTimelineMetricsSink.java    From ambari-metrics with Apache License 2.0 6 votes vote down vote up
@InterfaceAudience.Private
public void appendPrefix(MetricsRecord record, StringBuilder sb) {
  String contextName = record.context();
  Collection<MetricsTag> tags = record.tags();
  if (useTagsMap.containsKey(contextName)) {
    Set<String> useTags = useTagsMap.get(contextName);
    for (MetricsTag t : tags) {
      if (useTags == null || useTags.contains(t.name())) {

        // the context is always skipped here because it is always added

        // the hostname is always skipped to avoid case-mismatches
        // from different DNSes.

        if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) {
          sb.append('.').append(t.name()).append('=').append(t.value());
        }
      }
    }
  }
}
 
Example #5
Source File: AzureBlobStorageTestAccount.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public Number getLatestMetricValue(String metricName, Number defaultValue)
    throws IndexOutOfBoundsException{
  boolean found = false;
  Number ret = null;
  for (MetricsRecord currentRecord : allMetrics) {
    // First check if this record is coming for my file system.
    if (wasGeneratedByMe(currentRecord)) {
      for (AbstractMetric currentMetric : currentRecord.metrics()) {
        if (currentMetric.name().equalsIgnoreCase(metricName)) {
          found = true;
          ret = currentMetric.value();
          break;
        }
      }
    }
  }
  if (!found) {
    if (defaultValue != null) {
      return defaultValue;
    }
    throw new IndexOutOfBoundsException(metricName);
  }
  return ret;
}
 
Example #6
Source File: FileSink.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
  writer.print(record.timestamp());
  writer.print(" ");
  writer.print(record.context());
  writer.print(".");
  writer.print(record.name());
  String separator = ": ";
  for (MetricsTag tag : record.tags()) {
    writer.print(separator);
    separator = ", ";
    writer.print(tag.name());
    writer.print("=");
    writer.print(tag.value());
  }
  for (AbstractMetric metric : record.metrics()) {
    writer.print(separator);
    separator = ", ";
    writer.print(metric.name());
    writer.print("=");
    writer.print(metric.value());
  }
  writer.println();
}
 
Example #7
Source File: MetricsCache.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Update the cache and return the current cached record
 * @param mr the update record
 * @param includingTags cache tag values (for later lookup by name) if true
 * @return the updated cache record
 */
public Record update(MetricsRecord mr, boolean includingTags) {
  String name = mr.name();
  RecordCache recordCache = map.get(name);
  if (recordCache == null) {
    recordCache = new RecordCache();
    map.put(name, recordCache);
  }
  Collection<MetricsTag> tags = mr.tags();
  Record record = recordCache.get(tags);
  if (record == null) {
    record = new Record();
    recordCache.put(tags, record);
  }
  for (AbstractMetric m : mr.metrics()) {
    record.metrics.put(m.name(), m);
  }
  if (includingTags) {
    // mostly for some sinks that include tags as part of a dense schema
    for (MetricsTag t : mr.tags()) {
      record.tags.put(t.name(), t.value());
    }
  }
  return record;
}
 
Example #8
Source File: TestMetricsSystemImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
  final String prefix = "threadSourceRec";
  if (record.name().startsWith(prefix)) {
    final int recordNumber = Integer.parseInt(
        record.name().substring(prefix.length()));
    ArrayList<String> names = new ArrayList<String>();
    for (AbstractMetric m : record.metrics()) {
      if (m.name().equalsIgnoreCase("g1")) {
        collected[recordNumber].set(m.value().longValue());
        return;
      }
      names.add(m.name());
    }
  }
}
 
Example #9
Source File: TestMetricsSystemImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void checkMetricsRecords(List<MetricsRecord> recs) {
  LOG.debug(recs);
  MetricsRecord r = recs.get(0);
  assertEquals("name", "s1rec", r.name());
  assertEquals("tags", new MetricsTag[] {
    tag(MsInfo.Context, "test"),
    tag(MsInfo.Hostname, hostname)}, r.tags());
  assertEquals("metrics", MetricsLists.builder("")
    .addCounter(info("C1", "C1 desc"), 1L)
    .addGauge(info("G1", "G1 desc"), 2L)
    .addCounter(info("S1NumOps", "Number of ops for s1"), 1L)
    .addGauge(info("S1AvgTime", "Average time for s1"), 0.0)
    .metrics(), r.metrics());

  r = recs.get(1);
  assertTrue("NumActiveSinks should be 3", Iterables.contains(r.metrics(),
             new MetricGaugeInt(MsInfo.NumActiveSinks, 3)));
}
 
Example #10
Source File: GangliaSink30.java    From big-c with Apache License 2.0 6 votes vote down vote up
@InterfaceAudience.Private
public void appendPrefix(MetricsRecord record, StringBuilder sb) {
  String contextName = record.context();
  Collection<MetricsTag> tags = record.tags();
  if (useTagsMap.containsKey(contextName)) {
    Set<String> useTags = useTagsMap.get(contextName);
    for (MetricsTag t : tags) {
      if (useTags == null || useTags.contains(t.name())) {

        // the context is always skipped here because it is always added
        
        // the hostname is always skipped to avoid case-mismatches 
        // from different DNSes.

        if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) {
          sb.append('.').append(t.name()).append('=').append(t.value());
        }
      }
    }
  }          
}
 
Example #11
Source File: MetricsCache.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Update the cache and return the current cached record
 * @param mr the update record
 * @param includingTags cache tag values (for later lookup by name) if true
 * @return the updated cache record
 */
public Record update(MetricsRecord mr, boolean includingTags) {
  String name = mr.name();
  RecordCache recordCache = map.get(name);
  if (recordCache == null) {
    recordCache = new RecordCache();
    map.put(name, recordCache);
  }
  Collection<MetricsTag> tags = mr.tags();
  Record record = recordCache.get(tags);
  if (record == null) {
    record = new Record();
    recordCache.put(tags, record);
  }
  for (AbstractMetric m : mr.metrics()) {
    record.metrics.put(m.name(), m);
  }
  if (includingTags) {
    // mostly for some sinks that include tags as part of a dense schema
    for (MetricsTag t : mr.tags()) {
      record.tags.put(t.name(), t.value());
    }
  }
  return record;
}
 
Example #12
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
  final String prefix = "threadSourceRec";
  if (record.name().startsWith(prefix)) {
    final int recordNumber = Integer.parseInt(
        record.name().substring(prefix.length()));
    ArrayList<String> names = new ArrayList<String>();
    for (AbstractMetric m : record.metrics()) {
      if (m.name().equalsIgnoreCase("g1")) {
        collected[recordNumber].set(m.value().longValue());
        return;
      }
      names.add(m.name());
    }
  }
}
 
Example #13
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void checkMetricsRecords(List<MetricsRecord> recs) {
  LOG.debug(recs);
  MetricsRecord r = recs.get(0);
  assertEquals("name", "s1rec", r.name());
  assertEquals("tags", new MetricsTag[] {
    tag(MsInfo.Context, "test"),
    tag(MsInfo.Hostname, hostname)}, r.tags());
  assertEquals("metrics", MetricsLists.builder("")
    .addCounter(info("C1", "C1 desc"), 1L)
    .addGauge(info("G1", "G1 desc"), 2L)
    .addCounter(info("S1NumOps", "Number of ops for s1"), 1L)
    .addGauge(info("S1AvgTime", "Average time for s1"), 0.0)
    .metrics(), r.metrics());

  r = recs.get(1);
  assertTrue("NumActiveSinks should be 3", Iterables.contains(r.metrics(),
             new MetricGaugeInt(MsInfo.NumActiveSinks, 3)));
}
 
Example #14
Source File: PhoenixTraceReaderIT.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Test
public void singleSpan() throws Exception {
    PhoenixMetricsSink sink = new PhoenixMetricsSink();
    Properties props = new Properties(TEST_PROPERTIES);
    Connection conn = DriverManager.getConnection(getUrl(), props);
    sink.initForTesting(conn);

    // create a simple metrics record
    long traceid = 987654;
    MetricsRecord record =
            createAndFlush(sink, traceid, Span.ROOT_SPAN_ID, 10, "root", 12, 13,
                "host-name.value", "test annotation for a span");

    // start a reader
    validateTraces(Collections.singletonList(record), conn, traceid);
}
 
Example #15
Source File: LoggingSink.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
    // we could wait until flush, but this is a really lightweight process, so we just write
    // them
    // as soon as we get them
    if (!LOGGER.isDebugEnabled()) {
        return;
    }
    LOGGER.debug("Found record:" + record.name());
    for (AbstractMetric metric : record.metrics()) {
        // just print the metric we care about
        if (metric.name().startsWith(TracingUtils.METRIC_SOURCE_KEY)) {
            LOGGER.debug("\t metric:" + metric);
        }
    }
}
 
Example #16
Source File: FileSink.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
  writer.print(record.timestamp());
  writer.print(" ");
  writer.print(record.context());
  writer.print(".");
  writer.print(record.name());
  String separator = ": ";
  for (MetricsTag tag : record.tags()) {
    writer.print(separator);
    separator = ", ";
    writer.print(tag.name());
    writer.print("=");
    writer.print(tag.value());
  }
  for (AbstractMetric metric : record.metrics()) {
    writer.print(separator);
    separator = ", ";
    writer.print(metric.name());
    writer.print("=");
    writer.print(metric.value());
  }
  writer.println();
}
 
Example #17
Source File: AzureBlobStorageTestAccount.java    From big-c with Apache License 2.0 6 votes vote down vote up
public Number getLatestMetricValue(String metricName, Number defaultValue)
    throws IndexOutOfBoundsException{
  boolean found = false;
  Number ret = null;
  for (MetricsRecord currentRecord : allMetrics) {
    // First check if this record is coming for my file system.
    if (wasGeneratedByMe(currentRecord)) {
      for (AbstractMetric currentMetric : currentRecord.metrics()) {
        if (currentMetric.name().equalsIgnoreCase(metricName)) {
          found = true;
          ret = currentMetric.value();
          break;
        }
      }
    }
  }
  if (!found) {
    if (defaultValue != null) {
      return defaultValue;
    }
    throw new IndexOutOfBoundsException(metricName);
  }
  return ret;
}
 
Example #18
Source File: TestMetricsCache.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure metrics tag has a sane hashCode impl
 */
@Test public void testNullTag() {
  MetricsCache cache = new MetricsCache();
  MetricsRecord mr = makeRecord("r",
      Arrays.asList(makeTag("t", null)),
      Arrays.asList(makeMetric("m", 0), makeMetric("m1", 1)));

  MetricsCache.Record cr = cache.update(mr);
  assertTrue("t value should be null", null == cr.getTag("t"));
}
 
Example #19
Source File: MetricsRecords.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static void assertTag(MetricsRecord record, String tagName,
    String expectedValue) {
  MetricsTag processIdTag = getFirstTagByName(record,
      tagName);
  assertNotNull(processIdTag);
  assertEquals(expectedValue, processIdTag.value());
}
 
Example #20
Source File: TestMetricsCache.java    From big-c with Apache License 2.0 5 votes vote down vote up
private MetricsRecord makeRecord(String name, Collection<MetricsTag> tags,
                                 Collection<AbstractMetric> metrics) {
  MetricsRecord mr = mock(MetricsRecord.class);
  when(mr.name()).thenReturn(name);
  when(mr.tags()).thenReturn(tags);
  when(mr.metrics()).thenReturn(metrics);
  return mr;
}
 
Example #21
Source File: MetricsRecords.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static void assertMetric(MetricsRecord record,
    String metricName,
    Number expectedValue) {
  AbstractMetric resourceLimitMetric = getFirstMetricByName(
      record, metricName);
  assertNotNull(resourceLimitMetric);
  assertEquals(expectedValue, resourceLimitMetric.value());
}
 
Example #22
Source File: AzureBlobStorageTestAccount.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the given record was generated by my WASB file system instance.
 * @param currentRecord The metrics record to check.
 * @return
 */
private boolean wasGeneratedByMe(MetricsRecord currentRecord) {
  String myFsId = fs.getInstrumentation().getFileSystemInstanceId().toString();
  for (MetricsTag currentTag : currentRecord.tags()) {
    if (currentTag.name().equalsIgnoreCase("wasbFileSystemId")) {
      return currentTag.value().equals(myFsId);
    }
  }
  return false;
}
 
Example #23
Source File: TestGangliaMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testTagsForPrefix() throws Exception {
  ConfigBuilder cb = new ConfigBuilder()
    .add("test.sink.ganglia.tagsForPrefix.all", "*")
    .add("test.sink.ganglia.tagsForPrefix.some", "NumActiveSinks, " +
            "NumActiveSources")
    .add("test.sink.ganglia.tagsForPrefix.none", "");
  GangliaSink30 sink = new GangliaSink30();
  sink.init(cb.subset("test.sink.ganglia"));

  List<MetricsTag> tags = new ArrayList<MetricsTag>();
  tags.add(new MetricsTag(MsInfo.Context, "all"));
  tags.add(new MetricsTag(MsInfo.NumActiveSources, "foo"));
  tags.add(new MetricsTag(MsInfo.NumActiveSinks, "bar"));
  tags.add(new MetricsTag(MsInfo.NumAllSinks, "haa"));
  tags.add(new MetricsTag(MsInfo.Hostname, "host"));
  Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
  MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 1, tags, metrics);

  StringBuilder sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar.NumAllSinks=haa", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "some"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "none"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "nada"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());
}
 
Example #24
Source File: TestGraphiteMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutMetrics() {
    GraphiteSink sink = new GraphiteSink();
    List<MetricsTag> tags = new ArrayList<MetricsTag>();
    tags.add(new MetricsTag(MsInfo.Context, "all"));
    tags.add(new MetricsTag(MsInfo.Hostname, "host"));
    Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
    metrics.add(makeMetric("foo1", 1.25));
    metrics.add(makeMetric("foo2", 2.25));
    MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 10000, tags, metrics);

    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    final GraphiteSink.Graphite mockGraphite = makeGraphite();
    Whitebox.setInternalState(sink, "graphite", mockGraphite);
    sink.putMetrics(record);

    try {
      verify(mockGraphite).write(argument.capture());
    } catch (IOException e) {
      e.printStackTrace();
    }

    String result = argument.getValue();

    assertEquals(true,
        result.equals("null.all.Context.Context=all.Hostname=host.foo1 1.25 10\n" +
        "null.all.Context.Context=all.Hostname=host.foo2 2.25 10\n") ||
        result.equals("null.all.Context.Context=all.Hostname=host.foo2 2.25 10\n" + 
        "null.all.Context.Context=all.Hostname=host.foo1 1.25 10\n"));
}
 
Example #25
Source File: AzureBlobStorageTestAccount.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the given record was generated by my WASB file system instance.
 * @param currentRecord The metrics record to check.
 * @return
 */
private boolean wasGeneratedByMe(MetricsRecord currentRecord) {
  String myFsId = fs.getInstrumentation().getFileSystemInstanceId().toString();
  for (MetricsTag currentTag : currentRecord.tags()) {
    if (currentTag.name().equalsIgnoreCase("wasbFileSystemId")) {
      return currentTag.value().equals(myFsId);
    }
  }
  return false;
}
 
Example #26
Source File: TestGraphiteMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutMetrics2() {
    GraphiteSink sink = new GraphiteSink();
    List<MetricsTag> tags = new ArrayList<MetricsTag>();
    tags.add(new MetricsTag(MsInfo.Context, "all"));
  tags.add(new MetricsTag(MsInfo.Hostname, null));
    Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
    metrics.add(makeMetric("foo1", 1));
    metrics.add(makeMetric("foo2", 2));
    MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 10000, tags, metrics);


    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    final GraphiteSink.Graphite mockGraphite = makeGraphite();
    Whitebox.setInternalState(sink, "graphite", mockGraphite);
    sink.putMetrics(record);

    try {
        verify(mockGraphite).write(argument.capture());
    } catch (IOException e) {
        e.printStackTrace();
    }

    String result = argument.getValue();

    assertEquals(true,
        result.equals("null.all.Context.Context=all.foo1 1 10\n" + 
        "null.all.Context.Context=all.foo2 2 10\n") ||
        result.equals("null.all.Context.Context=all.foo2 2 10\n" + 
        "null.all.Context.Context=all.foo1 1 10\n"));
}
 
Example #27
Source File: GlobalPhoenixMetricsTestSink.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void putMetrics(MetricsRecord metricsRecord) {
    if (metricsRecord.name().equals(PHOENIX_METRICS_RECORD_NAME)) {
        synchronized (GlobalPhoenixMetricsTestSink.lock) {
            GlobalPhoenixMetricsTestSink.metrics = metricsRecord.metrics();
        }
    }
}
 
Example #28
Source File: TestContainerMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainerMetricsLimit() throws InterruptedException {
  final String ERR = "Error in number of records";

  MetricsSystem system = mock(MetricsSystem.class);
  doReturn(this).when(system).register(anyString(), anyString(), any());

  MetricsCollectorImpl collector = new MetricsCollectorImpl();
  ContainerId containerId = mock(ContainerId.class);
  ContainerMetrics metrics = ContainerMetrics.forContainer(containerId, 100);

  int anyPmemLimit = 1024;
  int anyVmemLimit = 2048;
  int anyVcores = 10;
  String anyProcessId = "1234";

  metrics.recordResourceLimit(anyVmemLimit, anyPmemLimit, anyVcores);
  metrics.recordProcessId(anyProcessId);

  Thread.sleep(110);
  metrics.getMetrics(collector, true);
  assertEquals(ERR, 1, collector.getRecords().size());
  MetricsRecord record = collector.getRecords().get(0);

  MetricsRecords.assertTag(record, ContainerMetrics.PROCESSID_INFO.name(),
      anyProcessId);

  MetricsRecords.assertMetric(record, ContainerMetrics
      .PMEM_LIMIT_METRIC_NAME, anyPmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VMEM_LIMIT_METRIC_NAME, anyVmemLimit);
  MetricsRecords.assertMetric(record, ContainerMetrics.VCORE_LIMIT_METRIC_NAME, anyVcores);

  collector.clear();
}
 
Example #29
Source File: TestPatternFilter.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a mock MetricsRecord with the given name and tags.
 * 
 * @param name String name
 * @param tags List<MetricsTag> tags
 * @return MetricsRecord newly created mock
 */
private static MetricsRecord mockMetricsRecord(String name,
    List<MetricsTag> tags) {
  MetricsRecord record = mock(MetricsRecord.class);
  when(record.name()).thenReturn(name);
  when(record.tags()).thenReturn(tags);
  return record;
}
 
Example #30
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void putMetrics(MetricsRecord record) {
  // No need to hang every time, just the first record.
  if (!firstTime) {
    gotCalledSecondTime = true;
    return;
  }
  firstTime = false;
  try {
    Thread.sleep(10 * 1000);
  } catch (InterruptedException ex) {
    interrupted = true;
  }
}