com.netflix.spectator.api.Counter.id()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(183)

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

Counter.id介绍

暂无

代码示例

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

@Override public Id id() {
 return get().id();
}

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

@Override protected Id id() {
 return counter.id();
}

代码示例来源:origin: com.netflix.spectator/spectator-api

@Override protected Id id() {
 return counter.id();
}

代码示例来源:origin: org.springframework.metrics/spring-metrics

@Override
public String getName() {
  return counter.id().name();
}

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

private void update(Counter counter) {
  T obj = ref.get();
  if (obj != null) {
   long current = f.applyAsLong(obj);
   if (current > previous) {
    final long delta = current - previous;
    LOGGER.trace("incrementing counter [{}] by {}", counter.id(), delta);
    counter.increment(delta);
   } else {
    LOGGER.trace("no update to counter [{}]: previous = {}, current = {}",
      counter.id(), previous, current);
   }
   previous = current;
  }
 }
}

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

@Override public Id id() {
 return get().id();
}

代码示例来源:origin: com.netflix.spectator/spectator-api

private void update(Counter counter) {
  T obj = ref.get();
  if (obj != null) {
   long current = f.applyAsLong(obj);
   if (current > previous) {
    final long delta = current - previous;
    LOGGER.trace("incrementing counter [{}] by {}", counter.id(), delta);
    counter.increment(delta);
   } else {
    LOGGER.trace("no update to counter [{}]: previous = {}, current = {}",
      counter.id(), previous, current);
   }
   previous = current;
  }
 }
}

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

@Test
public void testGet() {
 Registry r = newRegistry(5, true);
 Counter c = r.counter(r.createId("foo"));
 c.increment(42);
 Meter m = r.get(c.id());
 Assertions.assertEquals(c.measure().iterator().next(), m.measure().iterator().next());
}

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

@Test
public void iteratorDoesNotContainNullMeters() {
 Registry dflt = new ServoRegistry();
 boolean found = false;
 Counter counter = dflt.counter("servo.testCounter");
 for (Meter m : dflt) {
  found = m.id().equals(counter.id());
 }
 Assertions.assertTrue(found, "id could not be found in iterator");
}

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

@Test
public void testRegisterBadTypeAccessNoThrow() {
 Registry r = newRegistry(5, false);
 Counter c = new DefaultCounter(clock, r.createId("foo"));
 r.counter(c.id());
 r.register(c);
 Assertions.assertNotSame(r.get(c.id()), c);
}

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

@Test
 public void endpointUnknownIfNotSet() {
  Registry registry = new DefaultRegistry();
  IpcLogger logger = new IpcLogger(registry, clock, LoggerFactory.getLogger(getClass()));

  logger.createServerEntry()
    .withOwner("test")
    .markStart()
    .markEnd()
    .log();

  registry.counters().forEach(c -> {
   Assertions.assertEquals("unknown", Utils.getTagValue(c.id(), "ipc.endpoint"));
  });
 }
}

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

private void doMeasurementTest(Counter c, int expectedValue, long expectedTime) {
 c.increment(expectedValue);
 clock.setWallTime(expectedTime);
 List<Measurement> measurements = Utils.toList(c.measure());
 Assertions.assertEquals(1, measurements.size());
 Measurement m = measurements.get(0);
 Assertions.assertEquals(c.id(), m.id());
 Assertions.assertEquals(expectedTime, m.timestamp());
 Assertions.assertEquals(expectedValue, m.value(), 0.1e-12);
}

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

@Test
public void globalIterator() {
 Registry dflt = new DefaultRegistry();
 CompositeRegistry global = Spectator.globalRegistry();
 global.removeAll();
 global.add(dflt);
 boolean found = false;
 Counter counter = dflt.counter("testCounter");
 for (Meter m : global) {
  found |= m.id().equals(counter.id());
 }
 Assertions.assertTrue(found, "id for sub-registry could not be found in global iterator");
}

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

@Test
public void testIncrement() {
 String[] tagValue = new String[] { "default" };
 Counter c = factory.counter(factory.createId("testIncrement",
     Collections.singleton(new TestTagFactory(tagValue))));
 Assertions.assertEquals(0L, c.count());
 Assertions.assertEquals("testIncrement:tag=default", c.id().toString());
 c.increment();
 Assertions.assertEquals(1L, c.count());
 c.increment();
 c.increment();
 Assertions.assertEquals(3L, c.count());
 tagValue[0] = "value2";
 Assertions.assertEquals("testIncrement:tag=value2", c.id().toString());
 c.increment();
 Assertions.assertEquals(1L, c.count());
 tagValue[0] = "default";
 Assertions.assertEquals("testIncrement:tag=default", c.id().toString());
 c.increment();
 Assertions.assertEquals(4L, c.count());
}

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

@Test
 public void globalIteratorWithDifferences() {
  Registry r1 = new DefaultRegistry();
  Registry r2 = new DefaultRegistry();
  CompositeRegistry global = Spectator.globalRegistry();
  global.removeAll();
  global.add(r1);
  global.add(r2);

  boolean found = false;
  Counter counter = r2.counter("testCounter");
  for (Meter m : global) {
   found |= m.id().equals(counter.id());
  }
  Assertions.assertTrue(found, "id for sub-registry could not be found in global iterator");
 }
}

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

@Test
public void testMeasure() {
 Counter c = new DefaultCounter(clock, NoopId.INSTANCE);
 c.increment(42);
 clock.setWallTime(3712345L);
 for (Measurement m : c.measure()) {
  Assertions.assertEquals(m.id(), c.id());
  Assertions.assertEquals(m.timestamp(), 3712345L);
  Assertions.assertEquals(m.value(), 42.0, 0.1e-12);
 }
}

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

@Test
public void measure() {
 Counter c = newCounter();
 c.increment(42);
 clock.setWallTime(3712345L);
 for (Measurement m : c.measure()) {
  Assertions.assertEquals(m.id(), c.id());
  Assertions.assertEquals(m.timestamp(), 3712345L);
  Assertions.assertEquals(m.value(), 42.0, 0.1e-12);
 }
}

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

@Test
public void testRegister() {
 Registry r = newRegistry(5, true);
 Counter c = new DefaultCounter(clock, r.createId("foo"));
 r.register(c);
 c.increment();
 Assertions.assertEquals(c.count(), 1L);
 r.register(c);
 PolledMeter.update(r);
 Meter meter = r.get(c.id());
 for (Measurement m : meter.measure()) {
  Assertions.assertEquals(m.value(), 2.0, 1e-12);
 }
}

相关文章