use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class CompositeMeterRegistryAutoConfigurationTests method registerWhenHasMultipleMeterRegistriesShouldAddPrimaryComposite.
@Test
void registerWhenHasMultipleMeterRegistriesShouldAddPrimaryComposite() {
this.contextRunner.withUserConfiguration(MultipleMeterRegistriesConfig.class).run((context) -> {
assertThat(context.getBeansOfType(MeterRegistry.class)).hasSize(3).containsKeys("meterRegistryOne", "meterRegistryTwo", COMPOSITE_NAME);
MeterRegistry primary = context.getBean(MeterRegistry.class);
assertThat(primary).isInstanceOf(CompositeMeterRegistry.class);
assertThat(((CompositeMeterRegistry) primary).getRegistries()).hasSize(2);
assertThat(primary.config().clock()).isNotNull();
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class CompositeMeterRegistryAutoConfigurationTests method registerWhenHasMultipleRegistriesAndOneIsPrimaryShouldDoNothing.
@Test
void registerWhenHasMultipleRegistriesAndOneIsPrimaryShouldDoNothing() {
this.contextRunner.withUserConfiguration(MultipleMeterRegistriesWithOnePrimaryConfig.class).run((context) -> {
assertThat(context.getBeansOfType(MeterRegistry.class)).hasSize(2).containsKeys("meterRegistryOne", "meterRegistryTwo");
MeterRegistry primary = context.getBean(MeterRegistry.class);
assertThat(primary).isInstanceOf(TestMeterRegistry.class);
});
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithSinglePath.
@Test
void diskSpaceMetricsWithSinglePath() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
File path = new File(".");
DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Collections.singletonList(path), Tags.empty());
metricsBinder.bindTo(meterRegistry);
Tags tags = Tags.of("path", path.getAbsolutePath());
assertThat(meterRegistry.get("disk.free").tags(tags).gauge()).isNotNull();
assertThat(meterRegistry.get("disk.total").tags(tags).gauge()).isNotNull();
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class DiskSpaceMetricsBinderTests method diskSpaceMetricsWithCustomTags.
@Test
void diskSpaceMetricsWithCustomTags() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
File path = new File(".");
Tags customTags = Tags.of("foo", "bar");
DiskSpaceMetricsBinder metricsBinder = new DiskSpaceMetricsBinder(Collections.singletonList(path), customTags);
metricsBinder.bindTo(meterRegistry);
Tags tags = Tags.of("path", path.getAbsolutePath(), "foo", "bar");
assertThat(meterRegistry.get("disk.free").tags(tags).gauge()).isNotNull();
assertThat(meterRegistry.get("disk.total").tags(tags).gauge()).isNotNull();
}
use of io.micrometer.core.instrument.MeterRegistry in project snow-owl by b2ihealthcare.
the class RepositoryPlugin method preRun.
@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) {
if (env.isServer()) {
LOG.debug("Initializing repository plugin.");
final MeterRegistry registry = env.service(MeterRegistry.class);
final IEventBus eventBus = env.service(IEventBus.class);
// Add event bus based request metrics
registerRequestMetrics(registry, eventBus);
final IManagedContainer container = env.container();
RpcUtil.getInitialServerSession(container).registerServiceLookup(env::service);
Net4jUtil.prepareContainer(container);
JVMUtil.prepareContainer(container);
TCPUtil.prepareContainer(container);
LifecycleUtil.activate(container);
final HostAndPort hostAndPort = env.service(RepositoryConfiguration.class).getHostAndPort();
// open port in server environments
if (hostAndPort.getPort() > 0) {
// Starts the TCP transport
TCPUtil.getAcceptor(container, hostAndPort.toString());
LOG.info("Listening on {} for connections", hostAndPort);
}
// Starts the JVM transport
JVMUtil.getAcceptor(container, TransportClient.NET_4_J_CONNECTOR_NAME);
final RepositoryManager repositoryManager = new DefaultRepositoryManager();
env.services().registerService(RepositoryManager.class, repositoryManager);
env.services().registerService(RepositoryContextProvider.class, repositoryManager);
int numberOfWorkers = env.service(RepositoryConfiguration.class).getMaxThreads();
initializeRequestSupport(env, numberOfWorkers);
LOG.debug("Initialized repository plugin.");
} else {
LOG.debug("Snow Owl application is running in remote mode.");
}
if (env.isServer()) {
try {
connectSystemUser(env.container());
} catch (SnowowlServiceException e) {
throw new SnowowlRuntimeException(e);
}
}
}
Aggregations