Java Code Examples for io.micrometer.core.instrument.MeterRegistry#summary()

The following examples show how to use io.micrometer.core.instrument.MeterRegistry#summary() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistributionSummaryTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
@DisplayName("multiple recordings are maintained")
default void record(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");

    ds.record(10);
    clock(registry).add(step());

    ds.count();

    assertAll(() -> assertEquals(1L, ds.count()),
            () -> assertEquals(10L, ds.totalAmount()));

    ds.record(10);
    ds.record(10);
    clock(registry).add(step());

    assertAll(() -> assertTrue(ds.count() >= 2L),
            () -> assertTrue(ds.totalAmount() >= 20L));
}
 
Example 2
Source File: GRpcAgentFileStreamServiceImpl.java    From genie with Apache License 2.0 6 votes vote down vote up
private TransferManager(
    final ControlStreamManager controlStreamsManager,
    final TaskScheduler taskScheduler,
    final AgentFileStreamProperties properties,
    final MeterRegistry registry
) {
    this.controlStreamsManager = controlStreamsManager;
    this.taskScheduler = taskScheduler;
    this.properties = properties;
    this.registry = registry;
    this.transferTimeOutCounter = registry.counter(TRANSFER_TIMEOUT_COUNTER);
    this.transferSizeDistribution = registry.summary(TRANSFER_SIZE_DISTRIBUTION);

    this.taskScheduler.scheduleAtFixedRate(
        this::reapStalledTransfers,
        this.properties.getStalledTransferCheckInterval()
    );
}
 
Example 3
Source File: DistributionSummaryTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("negative quantities are ignored")
default void recordNegative(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");

    ds.record(-10);
    assertAll(() -> assertEquals(0, ds.count()),
            () -> assertEquals(0L, ds.totalAmount()));
}
 
Example 4
Source File: DistributionSummaryTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("record zero")
default void recordZero(MeterRegistry registry) {
    DistributionSummary ds = registry.summary("my.summary");

    ds.record(0);
    clock(registry).add(step());

    assertAll(() -> assertEquals(1L, ds.count()),
            () -> assertEquals(0L, ds.totalAmount()));
}
 
Example 5
Source File: GenieCpuHealthIndicator.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param healthProperties The maximum physical memory threshold
 * @param registry         Registry
 * @param taskScheduler    task scheduler
 */
public GenieCpuHealthIndicator(
    @NotNull final HealthProperties healthProperties,
    @NotNull final MeterRegistry registry,
    @NotNull final TaskScheduler taskScheduler
) {
    this(
        healthProperties.getMaxCpuLoadPercent(),
        healthProperties.getMaxCpuLoadConsecutiveOccurrences(),
        (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(),
        registry.summary("genie.cpuLoad"),
        taskScheduler
    );
}