Search in sources :

Example 1 with LoggingMeterRegistry

use of io.micrometer.core.instrument.logging.LoggingMeterRegistry in project java-operator-sdk by java-operator-sdk.

the class MySQLSchemaOperator method main.

public static void main(String[] args) throws IOException {
    log.info("MySQL Schema Operator starting");
    Config config = new ConfigBuilder().withNamespace(null).build();
    KubernetesClient client = new DefaultKubernetesClient(config);
    Operator operator = new Operator(client, new ConfigurationServiceOverrider(DefaultConfigurationService.instance()).withMetrics(new MicrometerMetrics(new LoggingMeterRegistry())).build());
    operator.register(new MySQLSchemaReconciler(client, MySQLDbConfig.loadFromEnvironmentVars()));
    operator.installShutdownHook();
    operator.start();
    new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD!")), 8080).start(Exit.NEVER);
}
Also used : Operator(io.javaoperatorsdk.operator.Operator) LoggingMeterRegistry(io.micrometer.core.instrument.logging.LoggingMeterRegistry) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) ConfigurationServiceOverrider(io.javaoperatorsdk.operator.api.config.ConfigurationServiceOverrider) TkFork(org.takes.facets.fork.TkFork) Config(io.fabric8.kubernetes.client.Config) FtBasic(org.takes.http.FtBasic) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) MicrometerMetrics(io.javaoperatorsdk.operator.monitoring.micrometer.MicrometerMetrics) FkRegex(org.takes.facets.fork.FkRegex)

Example 2 with LoggingMeterRegistry

use of io.micrometer.core.instrument.logging.LoggingMeterRegistry in project micrometer by micrometer-metrics.

the class Jersey3Main method main.

public static void main(String[] args) throws IOException {
    MeterRegistry registry = new LoggingMeterRegistry(new LoggingRegistryConfig() {

        @Override
        public String get(String key) {
            return null;
        }

        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }
    }, Clock.SYSTEM);
    HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
    Runtime.getRuntime().addShutdownHook(new Thread(() -> server.stop(0)));
    Application application = new ResourceConfig(HelloWorldResource.class).register(new MetricsApplicationEventListener(registry, new DefaultJerseyTagsProvider(), "http.server.requests", true));
    server.createContext("/", RuntimeDelegate.getInstance().createEndpoint(application, HttpHandler.class));
    server.start();
}
Also used : HttpHandler(com.sun.net.httpserver.HttpHandler) InetSocketAddress(java.net.InetSocketAddress) MetricsApplicationEventListener(io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener) LoggingRegistryConfig(io.micrometer.core.instrument.logging.LoggingRegistryConfig) Duration(java.time.Duration) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) LoggingMeterRegistry(io.micrometer.core.instrument.logging.LoggingMeterRegistry) LoggingMeterRegistry(io.micrometer.core.instrument.logging.LoggingMeterRegistry) HttpServer(com.sun.net.httpserver.HttpServer) DefaultJerseyTagsProvider(io.micrometer.core.instrument.binder.jersey.server.DefaultJerseyTagsProvider) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Application(jakarta.ws.rs.core.Application)

Example 3 with LoggingMeterRegistry

use of io.micrometer.core.instrument.logging.LoggingMeterRegistry in project micrometer by micrometer-metrics.

the class HazelcastCacheSample method main.

public static void main(String[] args) throws Exception {
    MeterRegistry registry = loggingMeterRegistry();
    IMap<String, Integer> hazelcastCache = Hazelcast.newHazelcastInstance().getMap("hazelcast.cache");
    HazelcastCacheMetrics.monitor(registry, hazelcastCache);
    for (int i = 0; i < 100; i++) {
        hazelcastCache.put("key" + i, i);
        Thread.sleep(1000);
    }
}
Also used : MeterRegistry(io.micrometer.core.instrument.MeterRegistry) LoggingMeterRegistry(io.micrometer.core.instrument.logging.LoggingMeterRegistry)

Example 4 with LoggingMeterRegistry

use of io.micrometer.core.instrument.logging.LoggingMeterRegistry in project micrometer by micrometer-metrics.

the class HazelcastCacheSample method main.

public static void main(String[] args) throws Exception {
    MeterRegistry registry = loggingMeterRegistry();
    IMap<String, Integer> hazelcastCache = Hazelcast.newHazelcastInstance().getMap("hazelcast.cache");
    HazelcastCacheMetrics.monitor(registry, hazelcastCache);
    for (int i = 0; i < 100; i++) {
        hazelcastCache.put("key" + i, i);
        Thread.sleep(1000);
    }
}
Also used : MeterRegistry(io.micrometer.core.instrument.MeterRegistry) LoggingMeterRegistry(io.micrometer.core.instrument.logging.LoggingMeterRegistry)

Aggregations

LoggingMeterRegistry (io.micrometer.core.instrument.logging.LoggingMeterRegistry)4 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)3 HttpHandler (com.sun.net.httpserver.HttpHandler)1 HttpServer (com.sun.net.httpserver.HttpServer)1 Config (io.fabric8.kubernetes.client.Config)1 ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)1 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 Operator (io.javaoperatorsdk.operator.Operator)1 ConfigurationServiceOverrider (io.javaoperatorsdk.operator.api.config.ConfigurationServiceOverrider)1 MicrometerMetrics (io.javaoperatorsdk.operator.monitoring.micrometer.MicrometerMetrics)1 DefaultJerseyTagsProvider (io.micrometer.core.instrument.binder.jersey.server.DefaultJerseyTagsProvider)1 MetricsApplicationEventListener (io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener)1 LoggingRegistryConfig (io.micrometer.core.instrument.logging.LoggingRegistryConfig)1 Application (jakarta.ws.rs.core.Application)1 InetSocketAddress (java.net.InetSocketAddress)1 Duration (java.time.Duration)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1 FkRegex (org.takes.facets.fork.FkRegex)1 TkFork (org.takes.facets.fork.TkFork)1