io.micrometer.statsd.StatsdConfig Java Examples

The following examples show how to use io.micrometer.statsd.StatsdConfig. 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 StatsdMeterRegistry datadogStatsd() {
    return new StatsdMeterRegistry(new StatsdConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

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

        @Override
        public StatsdFlavor flavor() {
            return StatsdFlavor.DATADOG;
        }
    }, Clock.SYSTEM);
}
 
Example #2
Source File: SampleRegistries.java    From micrometer with Apache License 2.0 6 votes vote down vote up
public static StatsdMeterRegistry telegrafStatsd() {
    return new StatsdMeterRegistry(new StatsdConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

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

        @Override
        public StatsdFlavor flavor() {
            return StatsdFlavor.TELEGRAF;
        }
    }, Clock.SYSTEM);
}
 
Example #3
Source File: SampleRegistries.java    From micrometer with Apache License 2.0 6 votes vote down vote up
public static StatsdMeterRegistry sysdigStatsd() {
    return new StatsdMeterRegistry(new StatsdConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

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

        @Override
        public StatsdFlavor flavor() {
            return StatsdFlavor.SYSDIG;
        }
    }, Clock.SYSTEM);
}
 
Example #4
Source File: SampleRegistries.java    From micrometer with Apache License 2.0 6 votes vote down vote up
public static StatsdMeterRegistry etsyStatsd() {
    return new StatsdMeterRegistry(new StatsdConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

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

        @Override
        public StatsdFlavor flavor() {
            return StatsdFlavor.ETSY;
        }
    }, Clock.SYSTEM);
}
 
Example #5
Source File: RegistryConfigUtilTest.java    From pravega with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatsDConfig() {
    MetricsConfig appConfig = MetricsConfig.builder()
            .with(MetricsConfig.OUTPUT_FREQUENCY, 37)
            .with(MetricsConfig.METRICS_PREFIX, "statsDPrefix")
            .with(MetricsConfig.STATSD_HOST, "localhost")
            .with(MetricsConfig.STATSD_PORT, 8225)
            .build();

    StatsdConfig testConfig = RegistryConfigUtil.createStatsDConfig(appConfig);
    assertTrue(37 == testConfig.step().getSeconds());
    assertEquals("statsDPrefix", testConfig.prefix());
    assertEquals("localhost", testConfig.host());
    assertTrue(8225 == testConfig.port());
    assertEquals(StatsdFlavor.TELEGRAF, testConfig.flavor());
    assertNull(testConfig.get("Undefined Key"));
}
 
Example #6
Source File: RegistryConfigUtil.java    From pravega with Apache License 2.0 5 votes vote down vote up
/**
 * Create StatsdConfig for StatsD Register.
 *
 * @param conf the metric config from Pravega.
 * @return instance of StatsdConfig to be used by StatsD Register.
 */
public static StatsdConfig createStatsDConfig(MetricsConfig conf) {
    log.info("Configuring stats with statsD at {}:{}", conf.getStatsDHost(), conf.getStatsDPort());
    return new StatsdConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(conf.getOutputFrequencySeconds().getSeconds());
        }

        @Override
        public String prefix() {
            return conf.getMetricsPrefix();
        }

        @Override
        public String host() {
            return conf.getStatsDHost();
        }

        @Override
        public int port() {
            return conf.getStatsDPort();
        }

        @Override
        public StatsdFlavor flavor() {
            return StatsdFlavor.TELEGRAF;
        }

        @Override
        public String get(String key) {
            return null; // accept the rest of the defaults; see https://micrometer.io/docs/registry/statsD.
        }
    };
}
 
Example #7
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);
    }
}