Search in sources :

Example 1 with MonitoringConfiguration

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());
    }
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) DefaultResourceURIPathResolver(com.b2international.snowowl.core.uri.DefaultResourceURIPathResolver) TimestampProvider(com.b2international.index.revision.TimestampProvider) ResourceTypeConverter(com.b2international.snowowl.core.ResourceTypeConverter) MonitoringConfiguration(com.b2international.snowowl.core.monitoring.MonitoringConfiguration) PathTerminologyResourceResolver(com.b2international.snowowl.core.repository.PathTerminologyResourceResolver)

Example 2 with MonitoringConfiguration

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;
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Index(com.b2international.index.Index) IndexSettings(com.b2international.snowowl.core.config.IndexSettings) ProcessorMetrics(io.micrometer.core.instrument.binder.system.ProcessorMetrics) ResourceTypeConverter(com.b2international.snowowl.core.ResourceTypeConverter) UptimeMetrics(io.micrometer.core.instrument.binder.system.UptimeMetrics) Plugin(com.b2international.snowowl.core.setup.Plugin) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) ResourceURIPathResolver(com.b2international.snowowl.core.uri.ResourceURIPathResolver) Mappings(com.b2international.index.mapping.Mappings) Indexes(com.b2international.index.Indexes) JvmGcMetrics(io.micrometer.core.instrument.binder.jvm.JvmGcMetrics) JvmMemoryMetrics(io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics) Environment(com.b2international.snowowl.core.setup.Environment) Map(java.util.Map) RevisionIndex(com.b2international.index.revision.RevisionIndex) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) SnowOwlConfiguration(com.b2international.snowowl.core.config.SnowOwlConfiguration) PathTerminologyResourceResolver(com.b2international.snowowl.core.repository.PathTerminologyResourceResolver) ClassPathScanner(com.b2international.snowowl.core.plugin.ClassPathScanner) FileDescriptorMetrics(io.micrometer.core.instrument.binder.system.FileDescriptorMetrics) Tag(io.micrometer.core.instrument.Tag) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) ClassLoaderMetrics(io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TimestampProvider(com.b2international.index.revision.TimestampProvider) DefaultResourceURIPathResolver(com.b2international.snowowl.core.uri.DefaultResourceURIPathResolver) ConfigurationRegistry(com.b2international.snowowl.core.setup.ConfigurationRegistry) Collectors(java.util.stream.Collectors) MonitoringConfiguration(com.b2international.snowowl.core.monitoring.MonitoringConfiguration) TerminologyRegistry(com.b2international.snowowl.core.terminology.TerminologyRegistry) LogbackMetrics(io.micrometer.core.instrument.binder.logging.LogbackMetrics) List(java.util.List) VersionDocument(com.b2international.snowowl.core.version.VersionDocument) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) JvmThreadMetrics(io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Maps.newHashMapWithExpectedSize(com.google.common.collect.Maps.newHashMapWithExpectedSize) Component(com.b2international.snowowl.core.plugin.Component) PrometheusConfig(io.micrometer.prometheus.PrometheusConfig) ProcessorMetrics(io.micrometer.core.instrument.binder.system.ProcessorMetrics) FileDescriptorMetrics(io.micrometer.core.instrument.binder.system.FileDescriptorMetrics) JvmMemoryMetrics(io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics) JvmGcMetrics(io.micrometer.core.instrument.binder.jvm.JvmGcMetrics) ClassLoaderMetrics(io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics) JvmThreadMetrics(io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics) Tag(io.micrometer.core.instrument.Tag) UptimeMetrics(io.micrometer.core.instrument.binder.system.UptimeMetrics) LogbackMetrics(io.micrometer.core.instrument.binder.logging.LogbackMetrics)

Aggregations

TimestampProvider (com.b2international.index.revision.TimestampProvider)2 ResourceTypeConverter (com.b2international.snowowl.core.ResourceTypeConverter)2 MonitoringConfiguration (com.b2international.snowowl.core.monitoring.MonitoringConfiguration)2 PathTerminologyResourceResolver (com.b2international.snowowl.core.repository.PathTerminologyResourceResolver)2 DefaultResourceURIPathResolver (com.b2international.snowowl.core.uri.DefaultResourceURIPathResolver)2 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)2 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)2 Index (com.b2international.index.Index)1 Indexes (com.b2international.index.Indexes)1 Mappings (com.b2international.index.mapping.Mappings)1 DefaultRevisionIndex (com.b2international.index.revision.DefaultRevisionIndex)1 RevisionIndex (com.b2international.index.revision.RevisionIndex)1 IndexSettings (com.b2international.snowowl.core.config.IndexSettings)1 RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)1 SnowOwlConfiguration (com.b2international.snowowl.core.config.SnowOwlConfiguration)1 ClassPathScanner (com.b2international.snowowl.core.plugin.ClassPathScanner)1 Component (com.b2international.snowowl.core.plugin.Component)1 ConfigurationRegistry (com.b2international.snowowl.core.setup.ConfigurationRegistry)1 Environment (com.b2international.snowowl.core.setup.Environment)1 Plugin (com.b2international.snowowl.core.setup.Plugin)1