use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class EmitterModuleTest method testParametrizedUriEmitterConfig.
@Test
public void testParametrizedUriEmitterConfig() {
final Properties props = new Properties();
props.setProperty("druid.emitter", "parametrized");
props.setProperty("druid.emitter.parametrized.recipientBaseUrlPattern", "http://example.com:8888/{feed}");
props.setProperty("druid.emitter.parametrized.httpEmitting.flushMillis", "1");
props.setProperty("druid.emitter.parametrized.httpEmitting.flushCount", "2");
props.setProperty("druid.emitter.parametrized.httpEmitting.basicAuthentication", "a:b");
props.setProperty("druid.emitter.parametrized.httpEmitting.batchingStrategy", "NEWLINES");
props.setProperty("druid.emitter.parametrized.httpEmitting.maxBatchSize", "4");
props.setProperty("druid.emitter.parametrized.httpEmitting.flushTimeOut", "1000");
final Emitter emitter = makeInjectorWithProperties(props).getInstance(Emitter.class);
// Testing that ParametrizedUriEmitter is successfully deserialized from the above config
Assert.assertThat(emitter, CoreMatchers.instanceOf(ParametrizedUriEmitter.class));
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class EmitterModuleTest method testMissingEmitterType.
@Test
public void testMissingEmitterType() {
final Properties props = new Properties();
props.setProperty("druid.emitter", "");
final Emitter emitter = makeInjectorWithProperties(props).getInstance(Emitter.class);
Assert.assertThat(emitter, CoreMatchers.instanceOf(NoopEmitter.class));
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class PrometheusEmitterTest method testEmitterMetric.
@Test
public void testEmitterMetric() {
PrometheusEmitterConfig config = new PrometheusEmitterConfig(PrometheusEmitterConfig.Strategy.pushgateway, "namespace", null, 0, "pushgateway");
PrometheusEmitterModule prometheusEmitterModule = new PrometheusEmitterModule();
Emitter emitter = prometheusEmitterModule.getEmitter(config);
ServiceMetricEvent build = ServiceMetricEvent.builder().setDimension("dataSource", "test").setDimension("taskType", "index_parallel").build("task/run/time", 500).build(ImmutableMap.of("service", "overlord"));
emitter.emit(build);
double assertEpsilon = 0.0001;
Assert.assertEquals(0.0, CollectorRegistry.defaultRegistry.getSampleValue("namespace_task_run_time_bucket", new String[] { "dataSource", "taskType", "le" }, new String[] { "test", "index_parallel", "0.1" }), assertEpsilon);
Assert.assertEquals(1.0, CollectorRegistry.defaultRegistry.getSampleValue("namespace_task_run_time_bucket", new String[] { "dataSource", "taskType", "le" }, new String[] { "test", "index_parallel", "0.5" }), assertEpsilon);
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class PrometheusEmitterTest method testEmitter.
@Test
public void testEmitter() {
PrometheusEmitterConfig config = new PrometheusEmitterConfig(PrometheusEmitterConfig.Strategy.exporter, null, null, 0, null);
PrometheusEmitterModule prometheusEmitterModule = new PrometheusEmitterModule();
Emitter emitter = prometheusEmitterModule.getEmitter(config);
ServiceMetricEvent build = ServiceMetricEvent.builder().setDimension("server", "druid-data01.vpc.region").build("segment/loadQueue/count", 10).build(ImmutableMap.of("service", "historical"));
Assert.assertEquals("historical", build.getService());
Assert.assertFalse(build.getUserDims().isEmpty());
emitter.emit(build);
Double count = CollectorRegistry.defaultRegistry.getSampleValue("druid_segment_loadqueue_count", new String[] { "server" }, new String[] { "druid_data01_vpc_region" });
Assert.assertEquals(10, count.intValue());
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class LoggingEmitterFactory method makeEmitter.
public Emitter makeEmitter(ObjectMapper objectMapper, Lifecycle lifecycle) {
Emitter retVal = new LoggingEmitter(this, objectMapper);
lifecycle.addManagedInstance(retVal);
return retVal;
}
Aggregations