use of io.micrometer.core.instrument.Meter in project spring-boot by spring-projects.
the class ConnectionPoolMetricsAutoConfigurationTests method allConnectionPoolsCanBeInstrumented.
@Test
void allConnectionPoolsCanBeInstrumented() {
this.contextRunner.withUserConfiguration(TwoConnectionPoolsConfiguration.class).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry.find("r2dbc.pool.acquired").gauges()).extracting(Meter::getId).extracting((id) -> id.getTag("name")).containsExactlyInAnyOrder("firstPool", "secondPool");
});
}
use of io.micrometer.core.instrument.Meter in project spring-boot by spring-projects.
the class RepositoryMetricsAutoConfigurationTests method timerWorksWithTimedAnnotationsWhenAutoTimeRequestsIsFalse.
@Test
void timerWorksWithTimedAnnotationsWhenAutoTimeRequestsIsFalse() {
this.contextRunner.withPropertyValues("management.metrics.data.repository.autotime.enabled=false").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context, ExampleAnnotatedRepository.class);
Collection<Meter> meters = registry.get("spring.data.repository.invocations").meters();
assertThat(meters).hasSize(1);
Meter meter = meters.iterator().next();
assertThat(meter.getId().getTag("method")).isEqualTo("count");
});
}
use of io.micrometer.core.instrument.Meter in project open-kilda by telstra.
the class PushToStreamMeterRegistry method pushMeters.
/**
* Push the current values of registered meters to the specified stream.
*/
public void pushMeters(OutputCollector collector, String streamId) {
try {
List<Datapoint> datapoints = new ArrayList<>();
for (Meter meter : getMeters()) {
datapoints.addAll(meter.match(this::writeGauge, this::writeCounter, this::writeTimer, this::writeSummary, this::writeLongTaskTimer, this::writeTimeGauge, this::writeFunctionCounter, this::writeFunctionTimer, this::writeCustomMeter));
}
String payload = Utils.MAPPER.writeValueAsString(new DatapointEntries(datapoints));
log.debug("Pushing datapoint(s) {}", payload);
collector.emit(streamId, Collections.singletonList(payload));
} catch (Exception ex) {
log.warn("Failed to send metrics", ex);
}
}
use of io.micrometer.core.instrument.Meter in project resilience4j by resilience4j.
the class BulkheadMetricsTest method shouldRegisterMetrics.
@Test
public void shouldRegisterMetrics() {
BulkheadRegistry bulkheadRegistry = BulkheadRegistry.ofDefaults();
bulkheadRegistry.bulkhead("testName");
BulkheadMetrics bulkheadMetrics = BulkheadMetrics.ofBulkheadRegistry(bulkheadRegistry);
bulkheadMetrics.bindTo(meterRegistry);
final List<String> metricNames = meterRegistry.getMeters().stream().map(Meter::getId).map(Meter.Id::getName).collect(Collectors.toList());
final List<String> expectedMetrics = newArrayList("resilience4j.bulkhead.testName.available_concurrent_calls");
assertThat(metricNames).hasSameElementsAs(expectedMetrics);
}
use of io.micrometer.core.instrument.Meter in project resilience4j by resilience4j.
the class RetryMetricsTest method shouldRegisterMetrics.
@Test
public void shouldRegisterMetrics() {
RetryRegistry retryRegistry = RetryRegistry.ofDefaults();
retryRegistry.retry("testName");
RetryMetrics retryMetrics = RetryMetrics.ofRetryRegistry(retryRegistry);
retryMetrics.bindTo(meterRegistry);
final List<String> metricNames = meterRegistry.getMeters().stream().map(Meter::getId).map(Meter.Id::getName).collect(Collectors.toList());
final List<String> expectedMetrics = newArrayList("resilience4j.retry.testName.successful_calls_with_retry", "resilience4j.retry.testName.failed_calls_with_retry", "resilience4j.retry.testName.successful_calls_without_retry", "resilience4j.retry.testName.failed_calls_without_retry");
assertThat(metricNames).hasSameElementsAs(expectedMetrics);
}
Aggregations