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

x33g5p2x  于2022-01-20 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(127)

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

Gauge.value介绍

[英]Returns the current value.
[中]返回当前值。

代码示例

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

@Override public double value() {
  return get().value();
 }
}

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

public void incCassStop() {
  cassStop.set(cassStop.value() + 1);
}

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

public void incCassAutoStart() {
  cassAutoStart.set(cassAutoStart.value() + 1);
}

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

public void incCassStart() {
  cassStart.set(cassStart.value() + 1);
}

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

@Test
public void testDynamicGauge() {
 DynamicGauge.set(CONFIG, 42.0);
 assertEquals(42.0, registry.gauge(ID).value(), 1e-12);
}

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

@Test
public void testDoubleGauge() {
 DoubleGauge c = new DoubleGauge(CONFIG);
 register(c);
 c.set(42.0);
 assertEquals(42.0, registry.gauge(ID).value(), 1e-12);
}

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

@Test
public void testBasicGauge() {
 BasicGauge<Double> c = new BasicGauge<>(CONFIG, () -> 42.0);
 register(c);
 PolledMeter.update(registry);
 assertEquals(42.0, registry.gauge(ID).value(), 1e-12);
}

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

@Test
public void testNumberGauge() {
 Number n = 42.0;
 NumberGauge c = new NumberGauge(CONFIG, n);
 register(c);
 PolledMeter.update(registry);
 assertEquals(42.0, registry.gauge(ID).value(), 1e-12);
}

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

@Test
public void testDoubleMaxGauge() {
 DoubleGauge c = new DoubleGauge(CONFIG);
 register(c);
 c.set(42.0);
 assertEquals(42.0, registry.maxGauge(ID).value(), 1e-12);
}

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

@Test
public void testPeakRateCounter() {
 PeakRateCounter c = new PeakRateCounter(CONFIG);
 DefaultMonitorRegistry.getInstance().register(c);
 c.increment();
 PolledMeter.update(registry);
 assertEquals(1.0, registry.gauge(ID).value());
}

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

@Test
public void testAnnotatedGauge() {
 AnnotateExample ex = new AnnotateExample("foo");
 PolledMeter.update(registry);
 Id id = registry.createId("gauge")
   .withTag("class", "AnnotateExample")
   .withTag("level", "INFO")
   .withTag("id", "foo");
 assertEquals(42.0, registry.gauge(id).value(), 1e-12);
}

代码示例来源: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 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 testMinGauge() {
 ManualClock clock = new ManualClock(0);
 MinGauge g = new MinGauge(CONFIG, clock);
 DefaultMonitorRegistry.getInstance().register(g);
 g.update(42);
 clock.set(60000);
 PolledMeter.update(registry);
 assertEquals(42.0, registry.gauge(ID).value());
}

代码示例来源: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 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 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);
}

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

@Test
public void testBucketTimerRecordMillis() {
 BucketConfig bc = new BucketConfig.Builder()
   .withBuckets(new long[] {10L, 50L})
   .withTimeUnit(TimeUnit.MILLISECONDS)
   .build();
 BucketTimer d = new BucketTimer(CONFIG, bc);
 register(d);
 d.record(42, TimeUnit.MILLISECONDS);
 Id id = ID.withTag("unit", "MILLISECONDS");
 assertEquals(1, registry.counter(id.withTag(Statistic.count).withTag("servo.bucket", "bucket=50ms")).count());
 assertEquals(42.0, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12);
 assertEquals(42.0, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12);
}

代码示例来源:origin: Netflix/concurrency-limits

@Test
public void testGuage() {
  DefaultRegistry registry = new DefaultRegistry();
  SpectatorMetricRegistry metricRegistry = new SpectatorMetricRegistry(registry, registry.createId("foo"));
  
  metricRegistry.registerGauge("bar", () -> 10);
  
  PolledMeter.update(registry);
  
  Assert.assertEquals(10.0, registry.gauge(registry.createId("foo.bar")).value(), 0);
}

代码示例来源:origin: Netflix/concurrency-limits

@Test
  public void testUnregister() {
    DefaultRegistry registry = new DefaultRegistry();
    SpectatorMetricRegistry metricRegistry = new SpectatorMetricRegistry(registry, registry.createId("foo"));
    
    metricRegistry.registerGauge("bar", () -> 10);
    metricRegistry.registerGauge("bar", () -> 20);
    
    PolledMeter.update(registry);
    
    Assert.assertEquals(20.0, registry.gauge(registry.createId("foo.bar")).value(), 0);
    
  }
}

相关文章