io.micrometer.jmx.JmxMeterRegistry Java Examples

The following examples show how to use io.micrometer.jmx.JmxMeterRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicrometerMetricsExamples.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
public void setupWithCompositeRegistry() {
  CompositeMeterRegistry myRegistry = new CompositeMeterRegistry();
  myRegistry.add(new JmxMeterRegistry(s -> null, Clock.SYSTEM));
  myRegistry.add(new GraphiteMeterRegistry(s -> null, Clock.SYSTEM));

  Vertx vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setMicrometerRegistry(myRegistry)
      .setEnabled(true)));
}
 
Example #2
Source File: SampleRegistries.java    From micrometer with Apache License 2.0 5 votes vote down vote up
public static JmxMeterRegistry jmx() {
    return new JmxMeterRegistry(new JmxConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

        @Override
        @Nullable
        public String get(String k) {
            return null;
        }
    }, Clock.SYSTEM);
}
 
Example #3
Source File: MicroMeterMetricCollector.java    From secor with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(SecorConfig config) {
    if (config.getMicroMeterCollectorStatsdEnabled()) {
        MeterRegistry statsdRegistry =
            new StatsdMeterRegistry(StatsdConfig.DEFAULT, Clock.SYSTEM);
        Metrics.addRegistry(statsdRegistry);
    }

    if (config.getMicroMeterCollectorJmxEnabled()) {
        MeterRegistry jmxRegistry = new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM);
        Metrics.addRegistry(jmxRegistry);
    }
}
 
Example #4
Source File: MetricsService.java    From ari-proxy with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void preStart() throws Exception {
	super.preStart();
	registry = new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM);
}
 
Example #5
Source File: JmxBackendRegistry.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
public JmxBackendRegistry(VertxJmxMetricsOptions options) {
  registry = new JmxMeterRegistry(options.toMicrometerConfig(), Clock.SYSTEM);
}
 
Example #6
Source File: MonitoringConfiguration.java    From waggle-dance with Apache License 2.0 4 votes vote down vote up
@Bean
public JmxMeterRegistry jmxMeterRegistry() {
  return new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM);
}
 
Example #7
Source File: Main.java    From blog-examples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    MeterRegistry registry = new JmxMeterRegistry(new JmxConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(1);
        }

        @Override
        public String get(String s) {
            return null;
        }
    }, Clock.SYSTEM);

    Counter counter = Counter
            .builder("my.counter")
            .description("counts something important")
            .tag("environment", "test")
            .tag("region", "us-east")
            .register(registry);

    counter.increment();
    counter.increment(2.5);

    Timer timer = Timer.builder("my.timer").register(registry);

    timer.record(() -> {
        System.out.println("sleeping");
        try {
            Thread.sleep(550);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    });

    timer.record(Duration.ofMillis(3));

    // Wait some time before application exit
    // This gives some time to use JConsole to connect to the
    // application and inspect the metrics
    System.out.println("Keeping application alive");
    Thread.sleep(240000);
    System.out.println("done");
}