io.micrometer.influx.InfluxMeterRegistry Java Examples

The following examples show how to use io.micrometer.influx.InfluxMeterRegistry. 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: SampleRegistries.java    From micrometer with Apache License 2.0 6 votes vote down vote up
public static InfluxMeterRegistry influx() {
    return new InfluxMeterRegistry(new InfluxConfig() {
        @Override
        public String userName() {
            return "admin";
        }

        @Override
        public String password() {
            return "admin";
        }

        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

        @Override
        @Nullable
        public String get(String k) {
            return null;
        }
    }, Clock.SYSTEM);
}
 
Example #2
Source File: StatsProviderImpl.java    From pravega with Apache License 2.0 6 votes vote down vote up
@Synchronized
@Override
public void start() {
    init();
    log.info("Metrics prefix: {}", conf.getMetricsPrefix());

    if (conf.isEnableStatsDReporter()) {
        metrics.add(new StatsdMeterRegistry(RegistryConfigUtil.createStatsDConfig(conf), Clock.SYSTEM));
    }

    if (conf.isEnableInfluxDBReporter()) {
        metrics.add(new InfluxMeterRegistry(RegistryConfigUtil.createInfluxConfig(conf), Clock.SYSTEM));
    }
    metrics.config().commonTags(createHostTag(DEFAULT_HOSTNAME_KEY));
    Preconditions.checkArgument(metrics.getRegistries().size() != 0,
            "No meter register bound hence no storage for metrics!");
}
 
Example #3
Source File: StatsProviderTest.java    From pravega with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatsProviderStartAndClose() {
    //To improve test case isolation, create a new registry instead of using the global one.
    CompositeMeterRegistry localRegistry = new CompositeMeterRegistry();

    MetricsConfig appConfig = MetricsConfig.builder()
            .with(MetricsConfig.ENABLE_STATSD_REPORTER, true)
            .with(MetricsConfig.ENABLE_INFLUXDB_REPORTER, false)
            .build();

    StatsProvider statsProvider = new StatsProviderImpl(appConfig, localRegistry);
    statsProvider.start();

    for (MeterRegistry registry : localRegistry.getRegistries()) {
        assertFalse(registry instanceof InfluxMeterRegistry);
        assertTrue(registry instanceof StatsdMeterRegistry);
    }

    statsProvider.close();
    assertTrue(0 == localRegistry.getRegistries().size());
}
 
Example #4
Source File: StatsProviderTest.java    From pravega with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatsProviderStartWithoutExporting() {
    MetricsConfig appConfig = MetricsConfig.builder()
            .with(MetricsConfig.ENABLE_STATSD_REPORTER, true)
            .with(MetricsConfig.ENABLE_INFLUXDB_REPORTER, true)
            .build();
    CompositeMeterRegistry localRegistry = new CompositeMeterRegistry();

    StatsProvider statsProvider = new StatsProviderImpl(appConfig, localRegistry);
    statsProvider.startWithoutExporting();

    for (MeterRegistry registry : localRegistry.getRegistries()) {
        assertTrue(registry instanceof SimpleMeterRegistry);
        assertFalse(registry instanceof InfluxMeterRegistry);
        assertFalse(registry instanceof StatsdMeterRegistry);
    }

    statsProvider.close();
    assertTrue(0 == localRegistry.getRegistries().size());
}
 
Example #5
Source File: InfluxDbBackendRegistry.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
public InfluxDbBackendRegistry(VertxInfluxDbOptions options) {
  registry = new InfluxMeterRegistry(options.toMicrometerConfig(), Clock.SYSTEM);
  registry.stop();
}