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

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

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

Counter.count介绍

[英]The cumulative count since this counter was last reset. How often a counter is reset depends on the underlying registry implementation.
[中]自上次重置此计数器以来的累计计数。计数器重置的频率取决于基础注册表实现。

代码示例

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

@Test
public void testDynamicCounterIncrement() {
 DynamicCounter.increment(CONFIG);
 assertEquals(1, registry.counter(ID).count());
}

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

@Test
public void testUnregisteredBasicCounterIncrement() {
 BasicCounter c = new BasicCounter(CONFIG);
 c.increment();
 assertEquals(1, registry.counters().count());
 assertEquals(1, registry.counter("test").count());
}

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

@Test
public void testStepCounterIncrementAmount() {
 StepCounter c = new StepCounter(CONFIG);
 register(c);
 c.increment(42);
 assertEquals(42, registry.counter(ID).count());
}

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

@Test
public void testStepCounterIncrement() {
 StepCounter c = new StepCounter(CONFIG);
 register(c);
 c.increment();
 assertEquals(1, registry.counter(ID).count());
}

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

@Test
public void testBasicCounterIncrementAmount() {
 BasicCounter c = new BasicCounter(CONFIG);
 register(c);
 c.increment(42);
 assertEquals(42, registry.counter(ID).count());
}

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

@Test
public void testBasicCounterIncrement() {
 BasicCounter c = new BasicCounter(CONFIG);
 register(c);
 c.increment();
 assertEquals(1, registry.counter(ID).count());
}

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

@Test
public void testAsyncDownloadFailure() throws Exception {
  Future<Path> future = failureFileSystem.asyncDownloadFile(Paths.get(""), null, 2);
  try {
    future.get();
  } catch (Exception e) {
    // Verify the failure metric for upload is incremented.
    Assert.assertEquals(1, (int) backupMetrics.getInvalidDownloads().count());
  }
}

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

@Test
public void testCustomCompositeMemberCounter() {
 CustomCompositeExample c = new CustomCompositeExample("foo");
 c.update("2");
 Id id = registry.createId("test").withTag("c", "2");
 assertEquals(1, registry.counter(id).count());
}

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

@Test
public void testCustomCounter() {
 CustomCounter c = new CustomCounter();
 register(c);
 c.increment();
 PolledMeter.update(registry);
 assertEquals(1, registry.counter(ID).count());
}

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

@Test
public void testBasicDistributionSummaryRecord() {
 BasicDistributionSummary d = new BasicDistributionSummary(CONFIG);
 register(d);
 d.record(42);
 assertEquals(1, registry.counter(ID.withTag(Statistic.count)).count());
 assertEquals(42, registry.counter(ID.withTag(Statistic.totalAmount)).count());
 assertEquals(42.0, registry.maxGauge(ID.withTag(Statistic.max)).value(), 1e-12);
}

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

@Test
public void testContextualCounter() {
 TagList context = BasicTagList.of("a", "1");
 ContextualCounter c = new ContextualCounter(CONFIG, () -> context, BasicCounter::new);
 c.increment();
 Id id = ID.withTag("a", "1");
 assertEquals(1, registry.counter(id).count());
}

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

@Test
public void testFailedRetriesDownload() {
  try {
    failureFileSystem.downloadFile(Paths.get(""), null, 2);
  } catch (BackupRestoreException e) {
    // Verify the failure metric for download is incremented.
    Assert.assertEquals(1, (int) backupMetrics.getInvalidDownloads().count());
  }
}

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

@Test
public void testFailedRetriesUpload() throws Exception {
  try {
    Collection<File> files = generateFiles(1, 1, 1);
    for (File file : files) {
      failureFileSystem.uploadFile(
          file.toPath(), file.toPath(), getDummyPath(file.toPath()), 2, true);
    }
  } catch (BackupRestoreException e) {
    // Verify the failure metric for upload is incremented.
    Assert.assertEquals(1, (int) backupMetrics.getInvalidUploads().count());
  }
}

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

@Test
public void testMemberCounter() {
 AnnotateExample ex = new AnnotateExample("foo");
 ex.update();
 Id id = registry.createId("test")
   .withTag("class", "AnnotateExample")
   .withTag("id", "foo");
 assertEquals(1, registry.counter(id).count());
}

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

@Test
public void testContextualMemberCounter() {
 ContextualExample c = new ContextualExample("foo");
 c.update();
 Id id = registry.createId("counter")
   .withTag("a", "2")
   .withTag("id", "foo")
   .withTag("class", "ContextualExample");
 assertEquals(1, registry.counter(id).count());
}

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

@Test
public void testAnnotatedCounter() {
 AnnotateExample ex = new AnnotateExample("foo");
 PolledMeter.update(registry);
 Id id = registry.createId("counter")
   .withTag("class", "AnnotateExample")
   .withTag("level", "INFO")
   .withTag("id", "foo");
 assertEquals(1, registry.counter(id).count());
}

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

@Test
public void testDynamicTimerRecordSeconds() {
 DynamicTimer.record(CONFIG, 42);
 Id id = ID.withTag("unit", "MILLISECONDS");
 assertEquals(1, registry.counter(id.withTag(Statistic.count)).count());
 assertEquals(42, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12);
 assertEquals(42 * 42, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12);
 assertEquals(42, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12);
}

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

@Test
public void testBasicTimerRecordMillis() {
 BasicTimer d = new BasicTimer(CONFIG);
 register(d);
 d.record(42, TimeUnit.NANOSECONDS);
 Id id = ID.withTag("unit", "MILLISECONDS");
 assertEquals(1, registry.counter(id.withTag(Statistic.count)).count());
 assertEquals(42e-6, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12);
 assertEquals(42e-6 * 42e-6, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12);
 assertEquals(42e-6, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12);
}

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

@Test
public void testBasicTimerRecordSeconds() {
 BasicTimer d = new BasicTimer(CONFIG, TimeUnit.SECONDS);
 register(d);
 d.record(42, TimeUnit.NANOSECONDS);
 Id id = ID.withTag("unit", "SECONDS");
 assertEquals(1, registry.counter(id.withTag(Statistic.count)).count());
 assertEquals(42e-9, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12);
 assertEquals(42e-9 * 42e-9, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12);
 assertEquals(42e-9, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12);
}

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

@Test
public void testContextualTimerRecordMillis() {
 TagList context = BasicTagList.of("a", "1");
 ContextualTimer d = new ContextualTimer(CONFIG, () -> context, BasicTimer::new);
 d.record(42, TimeUnit.NANOSECONDS);
 Id id = ID.withTag("unit", "MILLISECONDS").withTag("a", "1");
 assertEquals(1, registry.counter(id.withTag(Statistic.count)).count());
 assertEquals(42e-6, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12);
 assertEquals(42e-6 * 42e-6, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12);
 assertEquals(42e-6, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12);
}

相关文章