use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.
the class OpenTelemetryEmitterTest method testErrorStatus.
@Test
public void testErrorStatus() {
final ServiceMetricEvent queryTimeMetric = new ServiceMetricEvent.Builder().setDimension("success", "false").build(TIMESTAMP, "query/time", 100).build("druid/broker", "host");
emitter.emit(queryTimeMetric);
SpanData actualSpanData = noopExporter.spanDataCollection.iterator().next();
Assert.assertEquals(StatusCode.ERROR, actualSpanData.getStatus().getStatusCode());
}
use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.
the class OpenTelemetryEmitterTest method testOkStatus.
@Test
public void testOkStatus() {
final ServiceMetricEvent queryTimeMetric = new ServiceMetricEvent.Builder().setDimension("success", "true").build(TIMESTAMP, "query/time", 100).build("druid/broker", "host");
emitter.emit(queryTimeMetric);
SpanData actualSpanData = noopExporter.spanDataCollection.iterator().next();
Assert.assertEquals(StatusCode.OK, actualSpanData.getStatus().getStatusCode());
}
use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.
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.service.ServiceMetricEvent in project druid by apache.
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.service.ServiceMetricEvent in project druid by apache.
the class EventConverterTest method testConvertWithNamespacePrefixContainingSpace.
@Test
public void testConvertWithNamespacePrefixContainingSpace() {
DateTime dateTime = DateTimes.nowUtc();
ServiceMetricEvent configuredEvent = new ServiceMetricEvent.Builder().setDimension("dataSource", "foo:bar").setDimension("type", "groupBy").build(dateTime, "query/time", 10).build("druid:broker", "127.0.0.1:8080");
Map<String, Object> expectedTags = new HashMap<>();
expectedTags.put("service", "druid_broker");
expectedTags.put("host", "127.0.0.1_8080");
expectedTags.put("dataSource", "foo_bar");
expectedTags.put("type", "groupBy");
OpentsdbEvent opentsdbEvent = converterWithNamespacePrefixContainingSpace.convert(configuredEvent);
Assert.assertEquals("legendary_druid.query.time", opentsdbEvent.getMetric());
Assert.assertEquals(dateTime.getMillis() / 1000L, opentsdbEvent.getTimestamp());
Assert.assertEquals(10, opentsdbEvent.getValue());
Assert.assertEquals(expectedTags, opentsdbEvent.getTags());
ServiceMetricEvent notConfiguredEvent = new ServiceMetricEvent.Builder().setDimension("dataSource", "data-source").setDimension("type", "groupBy").build(dateTime, "foo/bar", 10).build("broker", "brokerHost1");
Assert.assertNull(converterWithNamespacePrefixContainingSpace.convert(notConfiguredEvent));
}
Aggregations