use of org.apache.flink.metrics.MetricConfig in project flink by apache.
the class PrometheusPushGatewayReporterTest method testConnectToPushGatewayUsingHostUrl.
@Test
void testConnectToPushGatewayUsingHostUrl() {
PrometheusPushGatewayReporterFactory factory = new PrometheusPushGatewayReporterFactory();
MetricConfig metricConfig = new MetricConfig();
metricConfig.setProperty(HOST_URL.key(), "https://localhost:18080");
PrometheusPushGatewayReporter reporter = factory.createMetricReporter(metricConfig);
String gatewayBaseURL = factory.createMetricReporter(metricConfig).hostUrl.toString();
assertThat(gatewayBaseURL).isEqualTo("https://localhost:18080");
}
use of org.apache.flink.metrics.MetricConfig in project flink by apache.
the class PrometheusPushGatewayReporterTest method testConnectToPushGatewayPreferHostUrl.
@Test
void testConnectToPushGatewayPreferHostUrl() {
PrometheusPushGatewayReporterFactory factory = new PrometheusPushGatewayReporterFactory();
MetricConfig metricConfig = new MetricConfig();
metricConfig.setProperty(HOST_URL.key(), "https://localhost:18080");
metricConfig.setProperty(HOST.key(), "localhost1");
metricConfig.setProperty(PORT.key(), "18081");
String gatewayBaseURL = factory.createMetricReporter(metricConfig).hostUrl.toString();
assertThat(gatewayBaseURL).isEqualTo("https://localhost:18080");
}
use of org.apache.flink.metrics.MetricConfig in project flink by apache.
the class PrometheusPushGatewayReporterTest method testConnectToPushGatewayThrowsExceptionWithoutHostInformation.
@Test
void testConnectToPushGatewayThrowsExceptionWithoutHostInformation() {
PrometheusPushGatewayReporterFactory factory = new PrometheusPushGatewayReporterFactory();
MetricConfig metricConfig = new MetricConfig();
assertThatThrownBy(() -> factory.createMetricReporter(metricConfig)).isInstanceOf(IllegalArgumentException.class);
metricConfig.setProperty(HOST.key(), "localhost");
assertThatThrownBy(() -> factory.createMetricReporter(metricConfig)).isInstanceOf(IllegalArgumentException.class);
metricConfig.clear();
metricConfig.setProperty(PORT.key(), "18080");
assertThatThrownBy(() -> factory.createMetricReporter(metricConfig)).isInstanceOf(IllegalArgumentException.class);
}
use of org.apache.flink.metrics.MetricConfig in project flink by apache.
the class PrometheusPushGatewayReporterTest method testConnectToPushGatewayUsingHostAndPort.
@Test
void testConnectToPushGatewayUsingHostAndPort() {
PrometheusPushGatewayReporterFactory factory = new PrometheusPushGatewayReporterFactory();
MetricConfig metricConfig = new MetricConfig();
metricConfig.setProperty(HOST.key(), "localhost");
metricConfig.setProperty(PORT.key(), "18080");
PrometheusPushGatewayReporter reporter = factory.createMetricReporter(metricConfig);
String gatewayBaseURL = factory.createMetricReporter(metricConfig).hostUrl.toString();
assertThat(gatewayBaseURL).isEqualTo("http://localhost:18080");
}
use of org.apache.flink.metrics.MetricConfig in project flink by apache.
the class StatsDReporterTest method testAddingMetrics.
/**
* Tests that the registered metrics' names don't contain invalid characters.
*/
@Test
void testAddingMetrics() {
String counterName = "testCounter";
final String scope = "scope";
final char delimiter = '_';
MetricGroup metricGroup = TestMetricGroup.newBuilder().setMetricIdentifierFunction((metricName, characterFilter) -> scope + delimiter + metricName).build();
TestingStatsDReporter reporter = new TestingStatsDReporter();
reporter.open(new MetricConfig());
SimpleCounter myCounter = new SimpleCounter();
reporter.notifyOfAddedMetric(myCounter, counterName, metricGroup);
Map<Counter, String> counters = reporter.getCounters();
assertThat(counters).containsKey(myCounter);
String expectedCounterName = reporter.filterCharacters(scope) + delimiter + reporter.filterCharacters(counterName);
assertThat(counters.get(myCounter)).isEqualTo(expectedCounterName);
}
Aggregations