本文整理了Java中io.micrometer.core.instrument.Gauge.getId()
方法的一些代码示例,展示了Gauge.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gauge.getId()
方法的具体详情如下:
包路径:io.micrometer.core.instrument.Gauge
类名称:Gauge
方法名:getId
暂无
代码示例来源:origin: de.codecentric/batch-web-spring-boot-autoconfigure
@Override
public String format(Collection<Gauge> gauges, Collection<Timer> timers) {
StringBuilder builder = new StringBuilder("\n########## Metrics Start ##########\n");
gauges.stream().forEach(gauge -> {
builder.append("Gauge [" + gauge.getId() + "]: ");
builder.append(gauge.value() + "\n");
});
timers.stream().forEach(timer -> {
builder.append("Timer [" + timer.getId() + "]: ");
builder.append(
"totalTime=" + timer.totalTime(timer.baseTimeUnit()) + " " + timer.baseTimeUnit() + "\n");
});
builder.append("########## Metrics End ############");
return builder.toString();
}
代码示例来源:origin: io.micrometer/micrometer-registry-new-relic
private Stream<String> writeGauge(Gauge gauge) {
Double value = gauge.value();
return value.isNaN() ? Stream.empty() : Stream.of(event(gauge.getId(), new Attribute("value", value)));
}
代码示例来源:origin: codecentric/spring-boot-starter-batch-web
@Override
public String format(Collection<Gauge> gauges, Collection<Timer> timers) {
StringBuilder builder = new StringBuilder("\n########## Metrics Start ##########\n");
gauges.stream().forEach(gauge -> {
builder.append("Gauge [" + gauge.getId() + "]: ");
builder.append(gauge.value() + "\n");
});
timers.stream().forEach(timer -> {
builder.append("Timer [" + timer.getId() + "]: ");
builder.append(
"totalTime=" + timer.totalTime(timer.baseTimeUnit()) + " " + timer.baseTimeUnit() + "\n");
});
builder.append("########## Metrics End ############");
return builder.toString();
}
代码示例来源:origin: io.micrometer/micrometer-registry-cloudwatch
private Stream<MetricDatum> gaugeData(Gauge gauge) {
double value = gauge.value();
if (!Double.isFinite(value))
return Stream.empty();
return Stream.of(metricDatum(gauge.getId(), "value", value));
}
代码示例来源:origin: jhipster/jhipster
private Map<String, Number> processMetrics() {
Map<String, Number> resultsProcess = new HashMap<>();
Collection<Gauge> gauges = Search.in(this.meterRegistry).name(s -> s.contains("cpu") || s.contains("system") || s.contains("process")).gauges();
gauges.forEach(gauge -> resultsProcess.put(gauge.getId().getName(), gauge.value()));
Collection<TimeGauge> timeGauges = Search.in(this.meterRegistry).name(s -> s.contains("process")).timeGauges();
timeGauges.forEach(gauge -> resultsProcess.put(gauge.getId().getName(), gauge.value(TimeUnit.MILLISECONDS)));
return resultsProcess;
}
代码示例来源:origin: io.micrometer/micrometer-registry-appoptics
Optional<String> writeGauge(Gauge gauge) {
double value = gauge.value();
if (!Double.isFinite(value)) {
return Optional.empty();
}
return Optional.of(write(gauge.getId(), "gauge", Fields.Value.tag(), decimal(value)));
}
代码示例来源:origin: jhipster/jhipster
private Map<String, Map<String, Number>> jvmMemoryMetrics() {
Map<String, Map<String, Number>> resultsJvm = new HashMap<>();
Search jvmUsedSearch = Search.in(this.meterRegistry).name(s -> s.contains("jvm.memory.used"));
Collection<Gauge> gauges = jvmUsedSearch.gauges();
gauges.forEach(gauge -> {
String key = gauge.getId().getTag("id");
resultsJvm.putIfAbsent(key, new HashMap<>());
resultsJvm.get(key).put("used", gauge.value());
});
Search jvmMaxSearch = Search.in(this.meterRegistry).name(s -> s.contains("jvm.memory.max"));
gauges = jvmMaxSearch.gauges();
gauges.forEach(gauge -> {
String key = gauge.getId().getTag("id");
resultsJvm.get(key).put("max", gauge.value());
});
gauges = Search.in(this.meterRegistry).name(s -> s.contains("jvm.memory.committed")).gauges();
gauges.forEach(gauge -> {
String key = gauge.getId().getTag("id");
resultsJvm.get(key).put("committed", gauge.value());
});
return resultsJvm;
}
代码示例来源:origin: jhipster/jhipster
private Map<String, Map<String, Number>> databaseMetrics() {
Map<String, Map<String, Number>> resultsDatabase = new HashMap<>();
Collection<Timer> timers = Search.in(this.meterRegistry).name(s -> s.contains("hikari")).timers();
timers.forEach(timer -> {
String key = timer.getId().getName().substring(timer.getId().getName().lastIndexOf('.') + 1);
resultsDatabase.putIfAbsent(key, new HashMap<>());
resultsDatabase.get(key).put("count", timer.count());
resultsDatabase.get(key).put("max", timer.max(TimeUnit.MILLISECONDS));
resultsDatabase.get(key).put("totalTime", timer.totalTime(TimeUnit.MILLISECONDS));
resultsDatabase.get(key).put("mean", timer.mean(TimeUnit.MILLISECONDS));
ValueAtPercentile[] percentiles = timer.takeSnapshot().percentileValues();
for (ValueAtPercentile percentile : percentiles) {
resultsDatabase.get(key).put(String.valueOf(percentile.percentile()), percentile.value(TimeUnit.MILLISECONDS));
}
});
Collection<Gauge> gauges = Search.in(this.meterRegistry).name(s -> s.contains("hikari")).gauges();
gauges.forEach(gauge -> {
String key = gauge.getId().getName().substring(gauge.getId().getName().lastIndexOf('.') + 1);
resultsDatabase.putIfAbsent(key, new HashMap<>());
resultsDatabase.get(key).put("value", gauge.value());
});
return resultsDatabase;
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
public synchronized T get(String... values) {
// This method is synchronized to make sure the "T" built via supplier will match the one passed to Gauge
// since it is stored as WeakReference in Micrometer DefaultGauge, it must not be lost.
T t = tSupplier.get();
// Register this gauge if necessary
// Note: we need here to go through the process of Gauge creation, even if it already exists,
// in order to get the Gauge ID. This ID generation is not trivial since it may involves attached MetricFilters.
// Micrometer will not register the gauge twice if it was already created.
Gauge g = Gauge.builder(name, t, dGetter)
.description(description)
.tags(Labels.toTags(keys, values))
.register(registry);
return gauges.computeIfAbsent(g.getId(), v -> t);
}
}
代码示例来源:origin: io.micrometer/micrometer-registry-kairos
Stream<String> writeGauge(Gauge gauge) {
Double value = gauge.value();
if (Double.isFinite(value)) {
return Stream.of(writeMetric(gauge.getId(), config().clock().wallTime(), value));
}
return Stream.empty();
}
代码示例来源:origin: jhipster/jhipster
private Map<String, Map<String, Number>> cacheMetrics() {
Map<String, Map<String, Number>> resultsCache = new HashMap<>();
Collection<FunctionCounter> counters = Search.in(this.meterRegistry).name(s -> s.contains("cache") && !s.contains("hibernate")).functionCounters();
counters.forEach(counter -> {
String name = counter.getId().getTag("name");
resultsCache.putIfAbsent(name, new HashMap<>());
String key = counter.getId().getName();
if (counter.getId().getTag("result") != null) {
key += "." + counter.getId().getTag("result");
}
resultsCache.get(name).put(key, counter.count());
});
Collection<Gauge> gauges = Search.in(this.meterRegistry).name(s -> s.contains("cache")).gauges();
gauges.forEach(gauge -> {
String name = gauge.getId().getTag("name");
resultsCache.putIfAbsent(name, new HashMap<>());
String key = gauge.getId().getName();
resultsCache.get(name).put(key, gauge.value());
});
return resultsCache;
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!