com.netflix.servo.monitor.Timer.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中com.netflix.servo.monitor.Timer.getValue()方法的一些代码示例,展示了Timer.getValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.getValue()方法的具体详情如下:
包路径:com.netflix.servo.monitor.Timer
类名称:Timer
方法名:getValue

Timer.getValue介绍

暂无

代码示例

代码示例来源:origin: Netflix/servo

/**
  * {@inheritDoc}
  */
 @Override
 public Long getValue(int pollerIndex) {
  return getMonitorForCurrentContext().getValue();
 }
}

代码示例来源:origin: Netflix/servo

@Test
public void testGetValue() throws Exception {
 Stopwatch s = DynamicTimer.start("test1", tagList);
 Timer c = getByName("test1");
 s.stop();
 // we don't call s.stop(), so we only have one recorded value
 assert c != null;
 assertEquals(c.getValue().longValue(), s.getDuration(TimeUnit.MILLISECONDS));
 c.record(13, TimeUnit.MILLISECONDS);
 long expected = (13 + s.getDuration(TimeUnit.MILLISECONDS)) / 2;
 assertEquals(c.getValue().longValue(), expected);
}

代码示例来源:origin: Netflix/servo

@Test
 public void testByStrings() throws Exception {
  Stopwatch s = DynamicTimer.start("byName");
  Stopwatch s2 = DynamicTimer.start("byName2", "key", "value");

  Thread.sleep(100L);

  s.stop();
  s2.stop();

  Timer c1 = getByName("byName");
  assert c1 != null;
  assertEquals(c1.getValue().longValue(), s.getDuration(TimeUnit.MILLISECONDS));

  Timer c2 = getByName("byName2");
  assert c2 != null;
  assertEquals(c2.getValue().longValue(), s2.getDuration(TimeUnit.MILLISECONDS));
 }
}

代码示例来源:origin: Netflix/servo

@Test
public void testExpiration() throws Exception {
 clock.set(0L);
 DynamicTimer.start("test1", tagList);
 DynamicTimer.start("test2", tagList);
 clock.set(500L);
 DynamicTimer.start("test1", tagList);
 clock.set(1000L);
 Stopwatch s = DynamicTimer.start("test1", tagList);
 clock.set(1200L);
 s.stop();
 Timer c1 = getByName("test1");
 assert c1 != null;
 assertEquals(c1.getValue().longValue(), s.getDuration(TimeUnit.MILLISECONDS));
 Thread.sleep(200L);
 Timer c2 = getByName("test2");
 assertNull(c2, "Timers not used in a while should expire");
}

代码示例来源:origin: com.netflix.servo/servo-core

/**
  * {@inheritDoc}
  */
 @Override
 public Long getValue(int pollerIndex) {
  return getMonitorForCurrentContext().getValue();
 }
}

相关文章