Polish
This commit is contained in:
@@ -49,8 +49,8 @@ public class DataSourcePoolMetrics implements MeterBinder {
|
||||
private final Iterable<Tag> tags;
|
||||
|
||||
public DataSourcePoolMetrics(DataSource dataSource,
|
||||
Collection<DataSourcePoolMetadataProvider> metadataProviders, String dataSourceName,
|
||||
Iterable<Tag> tags) {
|
||||
Collection<DataSourcePoolMetadataProvider> metadataProviders,
|
||||
String dataSourceName, Iterable<Tag> tags) {
|
||||
this(dataSource, new CompositeDataSourcePoolMetadataProvider(metadataProviders),
|
||||
dataSourceName, tags);
|
||||
}
|
||||
@@ -75,9 +75,10 @@ public class DataSourcePoolMetrics implements MeterBinder {
|
||||
}
|
||||
}
|
||||
|
||||
private <N extends Number> void bindPoolMetadata(MeterRegistry registry, String metricName,
|
||||
Function<DataSourcePoolMetadata, N> function) {
|
||||
bindDataSource(registry, metricName, this.metadataProvider.getValueFunction(function));
|
||||
private <N extends Number> void bindPoolMetadata(MeterRegistry registry,
|
||||
String metricName, Function<DataSourcePoolMetadata, N> function) {
|
||||
bindDataSource(registry, metricName,
|
||||
this.metadataProvider.getValueFunction(function));
|
||||
}
|
||||
|
||||
private <N extends Number> void bindDataSource(MeterRegistry registry,
|
||||
|
||||
@@ -43,8 +43,7 @@ public class RabbitMetricsTests {
|
||||
public void connectionFactoryWithTagsIsInstrumented() {
|
||||
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
|
||||
SimpleMeterRegistry registry = new SimpleMeterRegistry();
|
||||
new RabbitMetrics(connectionFactory, Tags.of("env", "prod"))
|
||||
.bindTo(registry);
|
||||
new RabbitMetrics(connectionFactory, Tags.of("env", "prod")).bindTo(registry);
|
||||
assertThat(registry.get("rabbitmq.connections").tags("env", "prod").meter())
|
||||
.isNotNull();
|
||||
assertThat(registry.find("rabbitmq.connections").tags("env", "dev").meter())
|
||||
|
||||
@@ -50,8 +50,8 @@ public class DataSourcePoolMetricsTests {
|
||||
"metrics.use-global-registry=false")
|
||||
.run((context) -> {
|
||||
context.getBean(DataSource.class).getConnection().getMetaData();
|
||||
context.getBean(MeterRegistry.class)
|
||||
.get("jdbc.max.connections").meter();
|
||||
context.getBean(MeterRegistry.class).get("jdbc.max.connections")
|
||||
.meter();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ public class MongoReactiveHealthIndicatorTest {
|
||||
Document buildInfo = mock(Document.class);
|
||||
given(buildInfo.getString("version")).willReturn("2.6.4");
|
||||
ReactiveMongoTemplate reactiveMongoTemplate = mock(ReactiveMongoTemplate.class);
|
||||
given(reactiveMongoTemplate.executeCommand("{ buildInfo: 1 }")).willReturn(
|
||||
Mono.just(buildInfo));
|
||||
|
||||
MongoReactiveHealthIndicator mongoReactiveHealthIndicator = new MongoReactiveHealthIndicator(reactiveMongoTemplate);
|
||||
given(reactiveMongoTemplate.executeCommand("{ buildInfo: 1 }"))
|
||||
.willReturn(Mono.just(buildInfo));
|
||||
MongoReactiveHealthIndicator mongoReactiveHealthIndicator = new MongoReactiveHealthIndicator(
|
||||
reactiveMongoTemplate);
|
||||
Mono<Health> health = mongoReactiveHealthIndicator.health();
|
||||
StepVerifier.create(health).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.UP);
|
||||
@@ -57,10 +57,10 @@ public class MongoReactiveHealthIndicatorTest {
|
||||
@Test
|
||||
public void testMongoIsDown() {
|
||||
ReactiveMongoTemplate reactiveMongoTemplate = mock(ReactiveMongoTemplate.class);
|
||||
given(reactiveMongoTemplate.executeCommand("{ buildInfo: 1 }")).willThrow(
|
||||
new MongoException("Connection failed"));
|
||||
|
||||
MongoReactiveHealthIndicator mongoReactiveHealthIndicator = new MongoReactiveHealthIndicator(reactiveMongoTemplate);
|
||||
given(reactiveMongoTemplate.executeCommand("{ buildInfo: 1 }"))
|
||||
.willThrow(new MongoException("Connection failed"));
|
||||
MongoReactiveHealthIndicator mongoReactiveHealthIndicator = new MongoReactiveHealthIndicator(
|
||||
reactiveMongoTemplate);
|
||||
Mono<Health> health = mongoReactiveHealthIndicator.health();
|
||||
StepVerifier.create(health).consumeNextWith((h) -> {
|
||||
assertThat(h.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
||||
Reference in New Issue
Block a user