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

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

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

Gauge.set介绍

[英]Set the current value of the gauge.
[中]设置仪表的当前值。

代码示例

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

private void incrementCurrentRequestsInFlight(ChannelHandlerContext ctx)
{
  currentRequestsGauge.set(currentRequests.incrementAndGet());
  ctx.channel().attr(ATTR_REQ_INFLIGHT).set(INFLIGHT);
}

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

private void decrementCurrentRequestsIfOneInflight(ChannelHandlerContext ctx)
  {
    if (ctx.channel().attr(ATTR_REQ_INFLIGHT).getAndRemove() != null) {
      currentRequestsGauge.set(currentRequests.decrementAndGet());
    }
  }
}

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

@Override public void set(double v) {
 get().set(v);
}

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

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

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

private void incrementCurrentRequestsInFlight(ChannelHandlerContext ctx)
{
  currentRequestsGauge.set(currentRequests.incrementAndGet());
  ctx.channel().attr(ATTR_REQ_INFLIGHT).set(INFLIGHT);
}

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

private void decrementCurrentRequestsIfOneInflight(ChannelHandlerContext ctx)
  {
    if (ctx.channel().attr(ATTR_REQ_INFLIGHT).getAndRemove() != null) {
      currentRequestsGauge.set(currentRequests.decrementAndGet());
    }
  }
}

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

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

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

private void setGaugeValue(String name, double v) {
 Id id = nameFunction.apply(name);
 if (id != null) {
  final double cv = valueFunction.convert(name, v);
  LOGGER.debug("setting gauge {} to {}", name, cv);
  spectatorRegistry.gauge(id).set(cv);
 }
}

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

@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: 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 measurementsWithGauge() {
 registry.gauge("test").set(4.0);
 Assertions.assertEquals(1, registry.getMeasurements().size());
}

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

@Test
public void maxGaugeSet() {
 Gauge g = registry.maxGauge("foo");
 Assertions.assertTrue(Double.isNaN(g.value()));
 g.set(42.0);
 g.set(20.0);
 clock.addSeconds(60);
 Assertions.assertEquals(42.0, g.value(), 1e-12);
}

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

@Test
 public void correctTypeForGaugesStream() {
  Registry r = newRegistry(5, false);
  r.gauge(r.createId("a")).set(1.0);
  r.gauge(r.createId("b")).set(2.0);
  Assertions.assertEquals(2, r.gauges().count());
  Assertions.assertEquals(2, r.stream().filter(m -> m instanceof Gauge).count());
 }
}

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

@Test
public void measurementsWithMaxGauge() {
 registry.maxGauge(registry.createId("test")).set(4.0);
 Assertions.assertEquals(1, registry.getMeasurements().size());
}

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

@Test
public void hasGaugeType() {
 final ServoRegistry r = new ServoRegistry(clock);
 Gauge g = r.gauge(r.createId("foo"));
 g.set(1.0);
 Map<String, String> tags = r.getMonitors().get(0).getConfig().getTags().asMap();
 Assertions.assertEquals("GAUGE", tags.get("type"));
}

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

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

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

@Test
public void gaugeMeasure() {
 Gauge g = registry.gauge("foo");
 g.set(42.0);
 int i = 0;
 for (Measurement m : g.measure()) {
  ++i;
  Assertions.assertEquals("foo", m.id().name());
  Assertions.assertEquals(42.0, m.value(), 1e-12);
 }
 Assertions.assertEquals(1, i);
}

相关文章