Start building against Micrometer 1.7.0-RC1 snapshots

See gh-25934
pull/25981/head
Stephane Nicoll 4 years ago
parent 555a3a79cb
commit d50e581403

@ -18,12 +18,12 @@ package org.springframework.boot.actuate.autoconfigure.metrics.mongo;
import com.mongodb.MongoClientSettings;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoMetricsCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoMetricsConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolTagsProvider;
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
@ -61,14 +61,14 @@ public class MongoMetricsAutoConfiguration {
@Bean
@ConditionalOnMissingBean
MongoMetricsCommandListener mongoMetricsCommandListener(MeterRegistry meterRegistry,
MongoMetricsCommandTagsProvider mongoMetricsCommandTagsProvider) {
return new MongoMetricsCommandListener(meterRegistry, mongoMetricsCommandTagsProvider);
MongoCommandTagsProvider mongoCommandTagsProvider) {
return new MongoMetricsCommandListener(meterRegistry, mongoCommandTagsProvider);
}
@Bean
@ConditionalOnMissingBean
MongoMetricsCommandTagsProvider mongoMetricsCommandTagsProvider() {
return new DefaultMongoMetricsCommandTagsProvider();
MongoCommandTagsProvider mongoCommandTagsProvider() {
return new DefaultMongoCommandTagsProvider();
}
@Bean
@ -87,14 +87,14 @@ public class MongoMetricsAutoConfiguration {
@Bean
@ConditionalOnMissingBean
MongoMetricsConnectionPoolListener mongoMetricsConnectionPoolListener(MeterRegistry meterRegistry,
MongoMetricsConnectionPoolTagsProvider mongoMetricsConnectionPoolTagsProvider) {
return new MongoMetricsConnectionPoolListener(meterRegistry, mongoMetricsConnectionPoolTagsProvider);
MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider) {
return new MongoMetricsConnectionPoolListener(meterRegistry, mongoConnectionPoolTagsProvider);
}
@Bean
@ConditionalOnMissingBean
MongoMetricsConnectionPoolTagsProvider mongoMetricsConnectionPoolTagsProvider() {
return new DefaultMongoMetricsConnectionPoolTagsProvider();
MongoConnectionPoolTagsProvider mongoMetricsConnectionPoolTagsProvider() {
return new DefaultMongoConnectionPoolTagsProvider();
}
@Bean

@ -22,12 +22,12 @@ import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.connection.ConnectionPoolSettings;
import com.mongodb.event.ConnectionPoolListener;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoMetricsCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoMetricsConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.DefaultMongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolTagsProvider;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
@ -60,8 +60,8 @@ class MongoMetricsAutoConfigurationTests {
assertThat(getActualMongoClientSettingsUsedToConstructClient(context)).isNotNull()
.extracting(MongoClientSettings::getCommandListeners).asList()
.containsExactly(context.getBean(MongoMetricsCommandListener.class));
assertThat(getMongoMetricsCommandTagsProviderUsedToConstructListener(context))
.isInstanceOf(DefaultMongoMetricsCommandTagsProvider.class);
assertThat(getMongoCommandTagsProviderUsedToConstructListener(context))
.isInstanceOf(DefaultMongoCommandTagsProvider.class);
});
}
@ -72,8 +72,8 @@ class MongoMetricsAutoConfigurationTests {
assertThat(context).hasSingleBean(MongoMetricsConnectionPoolListener.class);
assertThat(getConnectionPoolListenersFromClient(context))
.containsExactly(context.getBean(MongoMetricsConnectionPoolListener.class));
assertThat(getMongoMetricsConnectionPoolTagsProviderUsedToConstructListener(context))
.isInstanceOf(DefaultMongoMetricsConnectionPoolTagsProvider.class);
assertThat(getMongoConnectionPoolTagsProviderUsedToConstructListener(context))
.isInstanceOf(DefaultMongoConnectionPoolTagsProvider.class);
});
}
@ -91,24 +91,22 @@ class MongoMetricsAutoConfigurationTests {
@Test
void whenThereIsACustomMetricsCommandTagsProviderItIsUsed() {
final MongoMetricsCommandTagsProvider customTagsProvider = mock(MongoMetricsCommandTagsProvider.class);
final MongoCommandTagsProvider customTagsProvider = mock(MongoCommandTagsProvider.class);
this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
.withBean("customMongoMetricsCommandTagsProvider", MongoMetricsCommandTagsProvider.class,
() -> customTagsProvider)
.run((context) -> assertThat(getMongoMetricsCommandTagsProviderUsedToConstructListener(context))
.withBean("customMongoCommandTagsProvider", MongoCommandTagsProvider.class, () -> customTagsProvider)
.run((context) -> assertThat(getMongoCommandTagsProviderUsedToConstructListener(context))
.isSameAs(customTagsProvider));
}
@Test
void whenThereIsACustomMetricsConnectionPoolTagsProviderItIsUsed() {
final MongoMetricsConnectionPoolTagsProvider customTagsProvider = mock(
MongoMetricsConnectionPoolTagsProvider.class);
final MongoConnectionPoolTagsProvider customTagsProvider = mock(MongoConnectionPoolTagsProvider.class);
this.contextRunner.with(MetricsRun.simple())
.withConfiguration(AutoConfigurations.of(MongoAutoConfiguration.class))
.withBean("customMongoMetricsConnectionPoolTagsProvider", MongoMetricsConnectionPoolTagsProvider.class,
.withBean("customMongoConnectionPoolTagsProvider", MongoConnectionPoolTagsProvider.class,
() -> customTagsProvider)
.run((context) -> assertThat(getMongoMetricsConnectionPoolTagsProviderUsedToConstructListener(context))
.run((context) -> assertThat(getMongoConnectionPoolTagsProviderUsedToConstructListener(context))
.isSameAs(customTagsProvider));
}
@ -185,16 +183,16 @@ class MongoMetricsAutoConfigurationTests {
return listeners;
}
private MongoMetricsCommandTagsProvider getMongoMetricsCommandTagsProviderUsedToConstructListener(
private MongoCommandTagsProvider getMongoCommandTagsProviderUsedToConstructListener(
final AssertableApplicationContext context) {
MongoMetricsCommandListener listener = context.getBean(MongoMetricsCommandListener.class);
return (MongoMetricsCommandTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider");
return (MongoCommandTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider");
}
private MongoMetricsConnectionPoolTagsProvider getMongoMetricsConnectionPoolTagsProviderUsedToConstructListener(
private MongoConnectionPoolTagsProvider getMongoConnectionPoolTagsProviderUsedToConstructListener(
final AssertableApplicationContext context) {
MongoMetricsConnectionPoolListener listener = context.getBean(MongoMetricsConnectionPoolListener.class);
return (MongoMetricsConnectionPoolTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider");
return (MongoConnectionPoolTagsProvider) ReflectionTestUtils.getField(listener, "tagsProvider");
}
}

@ -1178,7 +1178,7 @@ bom {
]
}
}
library("Micrometer", "1.7.0-M1") {
library("Micrometer", "1.7.0-SNAPSHOT") {
group("io.micrometer") {
modules = [
"micrometer-registry-stackdriver" {

@ -2429,7 +2429,7 @@ Each metric is tagged with the following information by default:
| Outcome of the command - one of (`SUCCESS`, `FAILED`)
|===
To replace the default metric tags, define a `MongoMetricsCommandTagsProvider` bean, as shown in the following example:
To replace the default metric tags, define a `MongoCommandTagsProvider` bean, as shown in the following example:
[source,java,indent=0]
----
@ -2467,7 +2467,7 @@ Each metric is tagged with the following information by default:
| Address of the server the connection pool corresponds to
|===
To replace the default metric tags, define a `MongoMetricsConnectionPoolTagsProvider` bean, as shown in the following example:
To replace the default metric tags, define a `MongoConnectionPoolTagsProvider` bean, as shown in the following example:
[source,java,indent=0]
----

@ -18,7 +18,7 @@ package org.springframework.boot.docs.productionreadyfeatures.metrics.mongo;
import com.mongodb.event.CommandEvent;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -27,14 +27,14 @@ import org.springframework.context.annotation.Configuration;
public class SampleCommandTagsProviderConfiguration {
@Bean
MongoMetricsCommandTagsProvider customCommandTagsProvider() {
MongoCommandTagsProvider customCommandTagsProvider() {
return new CustomCommandTagsProvider();
}
}
// @chomp:file
class CustomCommandTagsProvider implements MongoMetricsCommandTagsProvider {
class CustomCommandTagsProvider implements MongoCommandTagsProvider {
@Override
public Iterable<Tag> commandTags(CommandEvent commandEvent) {

@ -19,7 +19,7 @@ package org.springframework.boot.docs.productionreadyfeatures.metrics.mongo;
// tag::code[]
import com.mongodb.event.ConnectionPoolCreatedEvent;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolTagsProvider;
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -28,14 +28,14 @@ import org.springframework.context.annotation.Configuration;
public class SampleConnectionPoolTagsProviderConfiguration {
@Bean
MongoMetricsConnectionPoolTagsProvider customConnectionPoolTagsProvider() {
MongoConnectionPoolTagsProvider customConnectionPoolTagsProvider() {
return new CustomConnectionPoolTagsProvider();
}
}
// end::code[]
class CustomConnectionPoolTagsProvider implements MongoMetricsConnectionPoolTagsProvider {
class CustomConnectionPoolTagsProvider implements MongoConnectionPoolTagsProvider {
@Override
public Iterable<Tag> connectionPoolTags(ConnectionPoolCreatedEvent event) {

Loading…
Cancel
Save