use of com.b2international.snowowl.core.monitoring.MonitoringConfiguration in project snow-owl by b2ihealthcare.
the class SnowOwlPlugin method init.
@Override
public void init(SnowOwlConfiguration configuration, Environment env) {
env.services().registerService(TerminologyRegistry.class, TerminologyRegistry.INSTANCE);
env.services().registerService(ResourceURIPathResolver.class, new DefaultResourceURIPathResolver(true));
env.services().registerService(PathTerminologyResourceResolver.class, new PathTerminologyResourceResolver.Default());
env.services().registerService(TimestampProvider.class, new TimestampProvider.Default());
env.services().registerService(ResourceTypeConverter.Registry.class, new ResourceTypeConverter.Registry(env.service(ClassPathScanner.class)));
// configure monitoring support
final MonitoringConfiguration monitoringConfig = configuration.getModuleConfig(MonitoringConfiguration.class);
if (monitoringConfig.isEnabled()) {
final PrometheusMeterRegistry registry = createRegistry(monitoringConfig);
env.services().registerService(MeterRegistry.class, registry);
} else {
// XXX this works like a NOOP registry if you do NOT register any additional registries to it
env.services().registerService(MeterRegistry.class, new CompositeMeterRegistry());
}
}
use of com.b2international.snowowl.core.monitoring.MonitoringConfiguration in project snow-owl by b2ihealthcare.
the class SnowOwlPlugin method createRegistry.
private PrometheusMeterRegistry createRegistry(final MonitoringConfiguration monitoringConfig) {
final PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
Map<String, String> tags = newHashMapWithExpectedSize(1 + monitoringConfig.getTags().size());
// always set the application tag to snow_owl
tags.put("application", "snow_owl");
// override with tags coming from the config file
tags.putAll(monitoringConfig.getTags());
// configure the tags
final List<Tag> commonTags = tags.entrySet().stream().map(entry -> Tag.of(entry.getKey(), entry.getValue())).collect(Collectors.toList());
registry.config().commonTags(commonTags);
// configure default JVM and node metrics
new ClassLoaderMetrics().bindTo(registry);
new JvmGcMetrics().bindTo(registry);
new JvmMemoryMetrics().bindTo(registry);
new JvmThreadMetrics().bindTo(registry);
new UptimeMetrics().bindTo(registry);
new ProcessorMetrics().bindTo(registry);
new LogbackMetrics().bindTo(registry);
new FileDescriptorMetrics().bindTo(registry);
return registry;
}
Aggregations