本文整理汇总了Java中io.micrometer.core.instrument.MeterRegistry类的典型用法代码示例。如果您正苦于以下问题:Java MeterRegistry类的具体用法?Java MeterRegistry怎么用?Java MeterRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MeterRegistry类属于io.micrometer.core.instrument包,在下文中一共展示了MeterRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: record
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Test
@DisplayName("total time is preserved for a single timing")
default void record(MeterRegistry registry) {
LongTaskTimer t = registry.more().longTaskTimer("myTimer");
LongTaskTimer.Sample sample = t.start();
clock(registry).add(10, TimeUnit.NANOSECONDS);
assertAll(() -> assertEquals(10, t.duration(TimeUnit.NANOSECONDS)),
() -> assertEquals(0.01, t.duration(TimeUnit.MICROSECONDS)),
() -> assertEquals(10, sample.duration(TimeUnit.NANOSECONDS)),
() -> assertEquals(0.01, sample.duration(TimeUnit.MICROSECONDS)),
() -> assertEquals(1, t.activeTasks()));
clock(registry).add(10, TimeUnit.NANOSECONDS);
sample.stop();
assertAll(() -> assertEquals(0, t.duration(TimeUnit.NANOSECONDS)),
() -> assertEquals(-1, sample.duration(TimeUnit.NANOSECONDS)),
() -> assertEquals(0, t.activeTasks()));
}
示例2: StatsdLineBuilder
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
StatsdLineBuilder(Meter.Id id, StatsdFlavor flavor, HierarchicalNameMapper nameMapper, MeterRegistry.Config config) {
this.id = id;
this.flavor = flavor;
this.nameMapper = nameMapper;
this.config = config;
// service:payroll,region:us-west
this.datadogTagString = memoize(convention ->
id.getTags().iterator().hasNext() ?
id.getConventionTags(convention).stream()
.map(t -> t.getKey() + ":" + t.getValue())
.collect(Collectors.joining(","))
: null
);
// service=payroll,region=us-west
this.telegrafTagString = memoize(convention ->
id.getTags().iterator().hasNext() ?
id.getConventionTags(convention).stream()
.map(t -> t.getKey() + "=" + t.getValue())
.collect(Collectors.joining(","))
: null
);
}
示例3: registry
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Override
public MeterRegistry registry() {
return new DatadogMeterRegistry(new DatadogConfig() {
@Override
public boolean enabled() {
return false;
}
@Override
public String apiKey() {
return "DOESNOTMATTER";
}
@Override
public String get(String k) {
return null;
}
}, new MockClock());
}
示例4: incrementAmount
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Test
@DisplayName("increment by a non-negative amount")
default void incrementAmount(MeterRegistry registry) {
Counter c = registry.counter("myCounter");
c.increment(2);
c.increment(0);
clock(registry).add(step());
assertEquals(2L, c.count());
}
示例5: bindTo
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
Gauge.builder("jvm.threads.peak", threadBean, ThreadMXBean::getPeakThreadCount)
.tags(tags)
.description("The peak live thread count since the Java virtual machine started or peak was reset")
.register(registry);
Gauge.builder("jvm.threads.daemon", threadBean, ThreadMXBean::getDaemonThreadCount)
.tags(tags)
.description("The current number of live daemon threads")
.register(registry);
Gauge.builder("jvm.threads.live", threadBean, ThreadMXBean::getThreadCount)
.tags(tags)
.description("The current number of live threads including both daemon and non-daemon threads")
.register(registry);
}
示例6: monitor
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
private void monitor(MeterRegistry registry, ThreadPoolExecutor tp) {
if (tp == null) {
return;
}
FunctionCounter.builder(name + ".completed", tp, ThreadPoolExecutor::getCompletedTaskCount)
.tags(tags)
.description("The approximate total number of tasks that have completed execution")
.register(registry);
Gauge.builder(name + ".active", tp, ThreadPoolExecutor::getActiveCount)
.tags(tags)
.description("The approximate number of threads that are actively executing tasks")
.register(registry);
Gauge.builder(name + ".queued", tp, tpRef -> tpRef.getQueue().size())
.tags(tags)
.description("The approximate number of threads that are queued for execution")
.register(registry);
Gauge.builder(name + ".pool", tp, ThreadPoolExecutor::getPoolSize)
.tags(tags)
.description("The current number of threads in the pool")
.register(registry);
}
示例7: bindTo
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
// Keeps references of existing Hystrix plugins.
HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier();
HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook();
HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();
HystrixPlugins.reset();
// Registers existing plugins except the new MicroMeter Strategy plugin.
HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(registry));
HystrixPlugins.getInstance().registerConcurrencyStrategy(concurrencyStrategy);
HystrixPlugins.getInstance().registerEventNotifier(eventNotifier);
HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy);
HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook);
}
示例8: main
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
public static void main(String[] args) {
MeterRegistry registry = SampleConfig.myMonitoringSystem();
GuavaCacheMetrics.monitor(registry, guavaCache, "book.guava");
// read all of Frankenstein
HttpClient.create("www.gutenberg.org")
.get("/cache/epub/84/pg84.txt")
.flatMapMany(res -> res.addHandler(wordDecoder()).receive().asString())
.delayElements(Duration.ofMillis(10)) // one word per 10 ms
.filter(word -> !word.isEmpty())
.doOnNext(word -> {
if (guavaCache.getIfPresent(word) == null)
guavaCache.put(word, 1);
})
.blockLast();
}
示例9: bindTo
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
Runtime runtime = Runtime.getRuntime();
Gauge.builder("system.cpu.count", runtime, Runtime::availableProcessors)
.tags(tags)
.description("The number of processors available to the Java virtual machine")
.register(registry);
OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
if(operatingSystemBean != null && operatingSystemBean.getSystemLoadAverage() >= 0) {
Gauge.builder("system.load.average.1m", operatingSystemBean, OperatingSystemMXBean::getSystemLoadAverage)
.tags(tags)
.description("The sum of the number of runnable entities queued to available processors and the number " +
"of runnable entities running on the available processors averaged over a period of time")
.register(registry);
}
}
示例10: registerNewMeter
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Override
DistributionSummary registerNewMeter(MeterRegistry registry) {
return DistributionSummary.builder(getId().getName())
.tags(getId().getTags())
.description(getId().getDescription())
.baseUnit(getId().getBaseUnit())
.publishPercentiles(histogramConfig.getPercentiles())
.publishPercentileHistogram(histogramConfig.isPercentileHistogram())
.maximumExpectedValue(histogramConfig.getMaximumExpectedValue())
.minimumExpectedValue(histogramConfig.getMinimumExpectedValue())
.histogramBufferLength(histogramConfig.getHistogramBufferLength())
.histogramExpiry(histogramConfig.getHistogramExpiry())
.sla(histogramConfig.getSlaBoundaries())
.register(registry);
}
示例11: remove
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
public final void remove(MeterRegistry registry) {
// Not very efficient, but this operation is expected to be used rarely.
final AtomicReference<T> firstMeterHolder = new AtomicReference<>();
children.removeIf(e -> {
if (e.registry() == registry) {
firstMeterHolder.compareAndSet(null, e.meter());
return true;
} else {
return false;
}
});
final T removedMeter = firstMeterHolder.get();
if (removedMeter != null) {
firstMeterUpdater.compareAndSet(this, removedMeter, null);
}
}
示例12: ImageService
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
public ImageService(ResourceLoader resourceLoader,
ImageRepository imageRepository,
MeterRegistry meterRegistry) {
this.resourceLoader = resourceLoader;
this.imageRepository = imageRepository;
this.meterRegistry = meterRegistry;
}
示例13: CommentController
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
public CommentController(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
this.flux = Flux.<Message<Comment>>create(
emitter -> this.commentSink = emitter,
FluxSink.OverflowStrategy.IGNORE)
.publish()
.autoConnect();
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:9,代码来源:CommentController.java
示例14: CommentController
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
public CommentController(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
this.flux = Flux.<Message<Comment>>create(
emitter -> this.commentSink = emitter,
FluxSink.OverflowStrategy.IGNORE)
.publish()
.autoConnect();
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:9,代码来源:CommentController.java
示例15: collectionSizeGauge
import io.micrometer.core.instrument.MeterRegistry; //导入依赖的package包/类
@Test
@DisplayName("gauges can be directly associated with collection size")
default void collectionSizeGauge(MeterRegistry registry) {
List<String> list = registry.gaugeCollectionSize("my.gauge", emptyList(), new ArrayList<>());
list.addAll(Arrays.asList("a", "b"));
Gauge g = registry.mustFind("my.gauge").gauge();
assertThat(g.value()).isEqualTo(2);
}