本文整理了Java中com.netflix.spectator.api.Registry.stream
方法的一些代码示例,展示了Registry.stream
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.stream
方法的具体详情如下:
包路径:com.netflix.spectator.api.Registry
类名称:Registry
方法名:stream
[英]Returns a stream of all registered meters.
[中]返回所有注册仪表的流。
代码示例来源:origin: Netflix/servo
@Test
public void testMinGaugeRemove() {
MinGauge g = new MinGauge(CONFIG);
DefaultMonitorRegistry.getInstance().register(g);
DefaultMonitorRegistry.getInstance().unregister(g);
g.update(42);
PolledMeter.update(registry);
assertEquals(0, registry.stream().count());
}
代码示例来源:origin: Netflix/servo
@Test
public void testPeakRateCounterRemove() {
PeakRateCounter c = new PeakRateCounter(CONFIG);
DefaultMonitorRegistry.getInstance().register(c);
DefaultMonitorRegistry.getInstance().unregister(c);
c.increment();
PolledMeter.update(registry);
assertEquals(0, registry.stream().count());
}
代码示例来源:origin: org.springframework.metrics/spring-metrics
@Override
public Stream<Meter> stream() {
return composite.stream();
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Returns a stream of all registered counters. This operation is mainly used for testing as
* a convenient way to get an aggregated value. For example, to generate a summary of all
* counters with name "foo":
*
* <pre>
* LongSummaryStatistics summary = r.counters()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingLong(Counter::count));
* </pre>
*/
default Stream<Counter> counters() {
return stream().filter(m -> m instanceof Counter).map(m -> (Counter) m);
}
代码示例来源:origin: Netflix/spectator
/**
* Returns a stream of all registered counters. This operation is mainly used for testing as
* a convenient way to get an aggregated value. For example, to generate a summary of all
* counters with name "foo":
*
* <pre>
* LongSummaryStatistics summary = r.counters()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingLong(Counter::count));
* </pre>
*/
default Stream<Counter> counters() {
return stream().filter(m -> m instanceof Counter).map(m -> (Counter) m);
}
代码示例来源:origin: Netflix/spectator
/**
* Returns a stream of all registered gauges. This operation is mainly used for testing as a
* convenient way to get an aggregated value. For example, to generate a summary of
* the values for all gauges with name "foo":
*
* <pre>
* DoubleSummaryStatistics valueSummary = r.gauges()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingDouble(Gauge::value));
*
* double sum = (double) valueSummary.getSum();
* </pre>
*/
default Stream<Gauge> gauges() {
return stream().filter(m -> m instanceof Gauge).map(m -> (Gauge) m);
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Returns a stream of all registered gauges. This operation is mainly used for testing as a
* convenient way to get an aggregated value. For example, to generate a summary of
* the values for all gauges with name "foo":
*
* <pre>
* DoubleSummaryStatistics valueSummary = r.gauges()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingDouble(Gauge::value));
*
* double sum = (double) valueSummary.getSum();
* </pre>
*/
default Stream<Gauge> gauges() {
return stream().filter(m -> m instanceof Gauge).map(m -> (Gauge) m);
}
代码示例来源:origin: Netflix/spectator
/**
* Returns a stream of all registered distribution summaries. This operation is mainly used for
* testing as a convenient way to get an aggregated value. For example, to generate a summary of
* the counts and total amounts for all distribution summaries with name "foo":
*
* <pre>
* LongSummaryStatistics countSummary = r.distributionSummaries()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingLong(DistributionSummary::count));
*
* LongSummaryStatistics totalSummary = r.distributionSummaries()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingLong(DistributionSummary::totalAmount));
*
* double avgAmount = (double) totalSummary.getSum() / countSummary.getSum();
* </pre>
*/
default Stream<DistributionSummary> distributionSummaries() {
return stream().filter(m -> m instanceof DistributionSummary).map(m -> (DistributionSummary) m);
}
代码示例来源:origin: Netflix/spectator
/**
* Returns a stream of all registered timers. This operation is mainly used for testing as a
* convenient way to get an aggregated value. For example, to generate a summary of
* the counts and total amounts for all timers with name "foo":
*
* <pre>
* LongSummaryStatistics countSummary = r.timers()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingLong(Timer::count));
*
* LongSummaryStatistics totalSummary = r.timers()
* .filter(Functions.nameEquals("foo"))
* .collect(Collectors.summarizingLong(Timer::totalTime));
*
* double avgTime = (double) totalSummary.getSum() / countSummary.getSum();
* </pre>
*/
default Stream<Timer> timers() {
return stream().filter(m -> m instanceof Timer).map(m -> (Timer) m);
}
代码示例来源:origin: Netflix/spectator
static Stream<Id> clientCallMetrics(Registry registry) {
return registry
.stream()
.map(Meter::id)
.filter(id -> "ipc.client.call".equals(id.name()));
}
代码示例来源:origin: Netflix/spectator
static Stream<Id> serverCallMetrics(Registry registry) {
return registry
.stream()
.map(Meter::id)
.filter(id -> "ipc.server.call".equals(id.name()));
}
代码示例来源:origin: Netflix/spectator
private static void validateIpcMeter(Registry registry, IpcMetric metric, Class<?> type) {
final String name = metric.metricName();
registry.stream()
.filter(m -> name.equals(m.id().name()) && !isPercentile(m.id()))
.forEach(m -> {
assertTrue(type.isAssignableFrom(m.getClass()),
"[%s] has the wrong type, expected %s but found %s",
m.id(), type.getSimpleName(), getName(m.getClass()));
metric.validate(m.id());
});
}
代码示例来源:origin: com.netflix.spectator/spectator-ext-ipc
private static void validateIpcMeter(Registry registry, IpcMetric metric, Class<?> type) {
final String name = metric.metricName();
registry.stream()
.filter(m -> name.equals(m.id().name()) && !isPercentile(m.id()))
.forEach(m -> {
assertTrue(type.isAssignableFrom(m.getClass()),
"[%s] has the wrong type, expected %s but found %s",
m.id(), type.getSimpleName(), getName(m.getClass()));
metric.validate(m.id());
});
}
代码示例来源:origin: Netflix/spectator
/** Returns a set of all values for a given tag key. */
private Set<String> valueSet(String k) {
return registry.stream()
.map(m -> Utils.getTagValue(m.id(), k))
.filter(v -> v != null)
.collect(Collectors.toSet());
}
代码示例来源:origin: Netflix/spectator
/** Returns a set of all values for a given tag key. */
private Set<String> valueSet(String k) {
return registry.stream()
.map(m -> Utils.getTagValue(m.id(), k))
.filter(v -> v != null)
.collect(Collectors.toSet());
}
代码示例来源:origin: Netflix/spectator
private static List<Measurement> getAllMeasurements(Registry registry) {
PolledMeter.update(registry);
final List<Measurement> result = new ArrayList<>();
registry.stream()
.filter(meter -> !meter.hasExpired())
.forEach(meter -> meter.measure().forEach(result::add));
return result;
}
代码示例来源:origin: Netflix/spectator
@Test
public void correctTypeForTimersStream() {
Registry r = newRegistry(5, false);
r.timer("a").record(1, TimeUnit.MICROSECONDS);
r.timer("b").record(1, TimeUnit.MICROSECONDS);
Assertions.assertEquals(2, r.timers().count());
Assertions.assertEquals(2, r.stream().filter(m -> m instanceof Timer).count());
}
代码示例来源:origin: Netflix/spectator
@Test
public void correctTypeForDistSummariesStream() {
Registry r = newRegistry(5, false);
r.distributionSummary("a").record(1);
r.distributionSummary("b").record(1);
Assertions.assertEquals(2, r.distributionSummaries().count());
Assertions.assertEquals(2, r.stream().filter(m -> m instanceof DistributionSummary).count());
}
代码示例来源:origin: Netflix/spectator
@Test
public void correctTypeForCountersStream() {
Registry r = newRegistry(5, false);
r.counter("a").increment();
r.counter("b").increment();
Assertions.assertEquals(2, r.counters().count());
Assertions.assertEquals(2, r.stream().filter(m -> m instanceof Counter).count());
}
代码示例来源: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());
}
}
内容来源于网络,如有侵权,请联系作者删除!