本文整理了Java中io.micrometer.core.instrument.Counter.getId()
方法的一些代码示例,展示了Counter.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Counter.getId()
方法的具体详情如下:
包路径:io.micrometer.core.instrument.Counter
类名称:Counter
方法名:getId
暂无
代码示例来源:origin: dev.rico/rico-metrics
@Override
public String getName() {
return counter.getId().getName();
}
代码示例来源:origin: yidongnan/grpc-spring-boot-starter
@Test
public void testClientCustomization() {
log.info("--- Starting tests with client customization ---");
final MeterRegistry meterRegistry = new SimpleMeterRegistry();
assertEquals(0, meterRegistry.getMeters().size());
final MetricCollectingClientInterceptor mcci = new MetricCollectingClientInterceptor(meterRegistry,
counter -> counter.tag("type", "counter"),
timer -> timer.tag("type", "timer").publishPercentiles(0.5, 0.9, 0.99),
OK, UNKNOWN);
mcci.preregisterService(TestServiceGrpc.getServiceDescriptor());
MetricTestHelper.logMeters(meterRegistry.getMeters());
assertEquals(METHOD_COUNT * 10, meterRegistry.getMeters().size());
final Counter counter = meterRegistry.find(METRIC_NAME_CLIENT_REQUESTS_SENT).counter();
assertNotNull(counter);
assertEquals("counter", counter.getId().getTag("type"));
final Timer timer = meterRegistry.find(METRIC_NAME_CLIENT_PROCESSING_DURATION).timer();
assertNotNull(timer);
assertEquals("timer", timer.getId().getTag("type"));
log.info("--- Test completed ---");
}
代码示例来源:origin: yidongnan/grpc-spring-boot-starter
@Test
public void testServerCustomization() {
log.info("--- Starting tests with server customization ---");
final MeterRegistry meterRegistry = new SimpleMeterRegistry();
assertEquals(0, meterRegistry.getMeters().size());
final MetricCollectingServerInterceptor mcsi = new MetricCollectingServerInterceptor(meterRegistry,
counter -> counter.tag("type", "counter"),
timer -> timer.tag("type", "timer").publishPercentiles(0.5, 0.9, 0.99),
OK, UNKNOWN);
mcsi.preregisterService(new TestServiceImpl());
MetricTestHelper.logMeters(meterRegistry.getMeters());
assertEquals(METHOD_COUNT * 10, meterRegistry.getMeters().size());
final Counter counter = meterRegistry.find(METRIC_NAME_SERVER_REQUESTS_RECEIVED).counter();
assertNotNull(counter);
assertEquals("counter", counter.getId().getTag("type"));
final Timer timer = meterRegistry.find(METRIC_NAME_SERVER_PROCESSING_DURATION).timer();
assertNotNull(timer);
assertEquals("timer", timer.getId().getTag("type"));
log.info("--- Test completed ---");
}
代码示例来源:origin: dev.rico/rico-metrics
@Override
public List<Context> getContext() {
return counter.getId().getTags()
.stream()
.map(t -> new ContextImpl(t.getKey(), t.getValue()))
.collect(Collectors.toList());
}
代码示例来源:origin: io.micrometer/micrometer-registry-cloudwatch
private Stream<MetricDatum> counterData(Counter counter) {
return Stream.of(metricDatum(counter.getId(), "count", counter.count()));
}
代码示例来源:origin: io.micrometer/micrometer-registry-appoptics
@Nullable
private Optional<String> writeCounter(Counter counter) {
double count = counter.count();
if (count > 0) {
// can't use "count" field because sum is required whenever count is set.
return Optional.of(write(counter.getId(), "counter", Fields.Value.tag(), decimal(count)));
}
return Optional.empty();
}
代码示例来源:origin: io.micrometer/micrometer-registry-new-relic
private Stream<String> writeCounter(Counter counter) {
return Stream.of(event(counter.getId(), new Attribute("throughput", counter.count())));
}
代码示例来源:origin: io.micrometer/micrometer-registry-kairos
Stream<String> writeCounter(Counter counter) {
return Stream.of(writeMetric(counter.getId(), config().clock().wallTime(), counter.count()));
}
代码示例来源:origin: jhipster/jhipster
private Map<String, Object> garbageCollectorMetrics() {
Map<String, Object> resultsGarbageCollector = new HashMap<>();
Collection<Timer> timers = Search.in(this.meterRegistry).name(s -> s.contains("jvm.gc.pause")).timers();
timers.forEach(timer -> {
String key = timer.getId().getName();
HashMap<String, Number> gcPauseResults = new HashMap<>();
gcPauseResults.put("count", timer.count());
gcPauseResults.put("max", timer.max(TimeUnit.MILLISECONDS));
gcPauseResults.put("totalTime", timer.totalTime(TimeUnit.MILLISECONDS));
gcPauseResults.put("mean", timer.mean(TimeUnit.MILLISECONDS));
ValueAtPercentile[] percentiles = timer.takeSnapshot().percentileValues();
for (ValueAtPercentile percentile : percentiles) {
gcPauseResults.put(String.valueOf(percentile.percentile()), percentile.value(TimeUnit.MILLISECONDS));
}
resultsGarbageCollector.putIfAbsent(key, gcPauseResults);
});
Collection<Gauge> gauges = Search.in(this.meterRegistry).name(s -> s.contains("jvm.gc") && !s.contains("jvm.gc.pause")).gauges();
gauges.forEach(gauge -> resultsGarbageCollector.put(gauge.getId().getName(), gauge.value()));
Collection<Counter> counters = Search.in(this.meterRegistry).name(s -> s.contains("jvm.gc") && !s.contains("jvm.gc.pause")).counters();
counters.forEach(counter -> resultsGarbageCollector.put(counter.getId().getName(), counter.count()));
gauges = Search.in(this.meterRegistry).name(s -> s.contains("jvm.classes.loaded")).gauges();
Double classesLoaded = gauges.stream().map(Gauge::value).reduce((x, y) -> (x + y)).orElse((double) 0);
resultsGarbageCollector.put("classesLoaded", classesLoaded);
Collection<FunctionCounter> functionCounters = Search.in(this.meterRegistry).name(s -> s.contains("jvm.classes.unloaded")).functionCounters();
Double classesUnloaded = functionCounters.stream().map(FunctionCounter::count).reduce((x, y) -> (x + y)).orElse((double) 0);
resultsGarbageCollector.put("classesUnloaded", classesUnloaded);
return resultsGarbageCollector;
}
代码示例来源:origin: io.micrometer/micrometer-test
@Test
@DisplayName("common tags are added to every measurement")
void addCommonTags(MeterRegistry registry) {
registry.config().commonTags("k", "v");
Counter c = registry.counter("foo");
assertThat(registry.get("foo").tags("k", "v").counter()).isSameAs(c);
assertThat(c.getId().getTagsAsIterable()).hasSize(1);
}
内容来源于网络,如有侵权,请联系作者删除!