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

x33g5p2x  于2022-01-28 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(232)

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

Registry.gauge介绍

[英]Tells the registry to regularly poll the value of a java.lang.Number and report it as a gauge. See #gauge(Id,Number) for more information.
[中]告诉注册表定期轮询java的值。lang.编号,并将其作为仪表报告。更多信息请参见#仪表(Id、编号)。

代码示例

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

private void openSslStatGauge(OpenSslSessionStats stats, String sslContextId, String statName, ToDoubleFunction<OpenSslSessionStats> value) {
  Id id = spectatorRegistry.createId("server.ssl.stats", "id", sslContextId, "stat", statName);
  spectatorRegistry.gauge(id, stats, value);
  LOG.debug("Registered spectator gauge - " + id.name());
}

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

private static AtomicLong getGauge(String className, String name, String... additionalTags) {
  Map<String, String> tags = toMap(className, additionalTags);
  return gauges.computeIfAbsent(name, s -> new ConcurrentHashMap<>()).computeIfAbsent(tags, t -> {
    Id id = registry.createId(name, tags);
    return registry.gauge(id, new AtomicLong(0));
  });
}

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

private void updateGauge(Id gaugeId, int value)
  {
    registry.gauge(gaugeId.withTag("eventloop", name)).set(value);
  }
}

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

public HttpMetricsChannelHandler(Registry registry, String name, String id)
{
  super();
  this.registry = registry;
  this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id));
  this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id);
}

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

private void openSslStatGauge(OpenSslSessionStats stats, String sslContextId, String statName, ToDoubleFunction<OpenSslSessionStats> value) {
  Id id = spectatorRegistry.createId("server.ssl.stats", "id", sslContextId, "stat", statName);
  spectatorRegistry.gauge(id, stats, value);
  LOG.debug("Registered spectator gauge - " + id.name());
}

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

public HttpMetricsChannelHandler(Registry registry, String name, String id)
{
  super();
  this.registry = registry;
  this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id));
  this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id);
}

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

private void updateGauge(Id gaugeId, int value)
  {
    registry.gauge(gaugeId.withTag("eventloop", name)).set(value);
  }
}

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

@Inject
public CassMonitorMetrics(Registry registry) {
  cassStop = registry.gauge(Metrics.METRIC_PREFIX + "cass.stop");
  cassStart = registry.gauge(Metrics.METRIC_PREFIX + "cass.start");
  cassAutoStart = registry.gauge(Metrics.METRIC_PREFIX + "cass.auto.start");
  getSeedsCnt =
      PolledMeter.using(registry)
          .withName(Metrics.METRIC_PREFIX + "cass.getSeedCnt")
          .monitorMonotonicCounter(new AtomicLong(0));
  getTokenCnt =
      PolledMeter.using(registry)
          .withName(Metrics.METRIC_PREFIX + "cass.getTokenCnt")
          .monitorMonotonicCounter(new AtomicLong(0));
  getReplacedIpCnt =
      PolledMeter.using(registry)
          .withName(Metrics.METRIC_PREFIX + "cass.getReplacedIpCnt")
          .monitorMonotonicCounter(new AtomicLong(0));
  doubleRingCnt =
      PolledMeter.using(registry)
          .withName(Metrics.METRIC_PREFIX + "cass.doubleRingCnt")
          .monitorMonotonicCounter(new AtomicLong(0));
}

代码示例来源: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 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 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 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 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 testStatsTimerRecordMillis() {
 StatsConfig sc = new StatsConfig.Builder()
   .withPercentiles(new double[] {50.0, 95.0})
   .withPublishCount(true)
   .withPublishMax(true)
   .withPublishMean(true)
   .withSampleSize(10)
   .build();
 StatsTimer d = new StatsTimer(CONFIG, sc);
 register(d);
 d.record(42, TimeUnit.MILLISECONDS);
 d.computeStats();
 Id id = ID.withTag("unit", "MILLISECONDS");
 assertEquals(1, registry.counter(id.withTag(Statistic.count)).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);
 assertEquals(42.0, registry.gauge(id.withTag("statistic", "percentile_50")).value(), 1e-12);
 assertEquals(42.0, registry.gauge(id.withTag("statistic", "percentile_95")).value(), 1e-12);
 assertEquals(42.0, registry.gauge(id.withTag("statistic", "avg")).value(), 1e-12);
}

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

/**
 * Represents a value sampled from another source.
 *
 * @param name
 *     Description of the measurement that is being collected.
 * @return
 *     Gauge instance with the corresponding id.
 */
default Gauge gauge(String name) {
 return gauge(createId(name));
}

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

public HttpMetricsChannelHandler(Registry registry, String name, String id)
{
  super();
  this.registry = registry;
  this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id));
  this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id);
}

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

@Override protected void update(Registry registry) {
  for (Measurement m : measure()) {
   LOGGER.trace("setting gauge [{}] to {}", m.id(), m.value());
   registry.gauge(m.id()).set(m.value());
  }
 }
}

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

@Test
public void testGaugeHelpersWithCustomFunction2() {
 AtomicLong al1 = new AtomicLong(1L);
 Registry r = new DefaultRegistry(new ManualClock(40, 0));
 ToDoubleFunction<AtomicLong> f = (obj) -> (r.clock().wallTime() - obj.doubleValue()) / 1000.0;
 AtomicLong v1 = r.gauge("foo", al1, f);
 Assertions.assertSame(v1, al1);
 Id id1 = r.createId("foo");
 assertGaugeValue(r, id1, 39.0 / 1000.0);
}

相关文章