This commit is contained in:
Phillip Webb
2018-01-18 23:10:28 -08:00
parent 6d93573db0
commit f3379668ac
51 changed files with 139 additions and 158 deletions

View File

@@ -42,7 +42,7 @@ public class RabbitMetrics implements MeterBinder {
private final ConnectionFactory connectionFactory;
/**
* Create a new meter binder recording the specified {@link ConnectionFactory}.
* Create a new meter binder recording the specified {@link ConnectionFactory}.
* @param connectionFactory the {@link ConnectionFactory} to instrument
* @param name the name prefix of the metrics
* @param tags tags to apply to all recorded metrics
@@ -53,13 +53,13 @@ public class RabbitMetrics implements MeterBinder {
Assert.notNull(name, "Name must not be null");
this.connectionFactory = connectionFactory;
this.name = name;
this.tags = (tags != null ? tags : Collections.EMPTY_LIST);
this.tags = (tags != null ? tags : Collections.emptyList());
}
@Override
public void bindTo(MeterRegistry registry) {
this.connectionFactory.setMetricsCollector(new MicrometerMetricsCollector(
registry, this.name, this.tags));
this.connectionFactory.setMetricsCollector(
new MicrometerMetricsCollector(registry, this.name, this.tags));
}
}

View File

@@ -45,10 +45,10 @@ public class RabbitMetricsTests {
SimpleMeterRegistry registry = new SimpleMeterRegistry();
new RabbitMetrics(connectionFactory, "test", Tags.zip("env", "prod"))
.bindTo(registry);
assertThat(registry.find("test.connections")
.tags("env", "prod").meter()).isPresent();
assertThat(registry.find("test.connections")
.tags("env", "dev").meter()).isNotPresent();
assertThat(registry.find("test.connections").tags("env", "prod").meter())
.isPresent();
assertThat(registry.find("test.connections").tags("env", "dev").meter())
.isNotPresent();
}
private ConnectionFactory mockConnectionFactory() {