Search in sources :

Example 36 with ServiceMetricEvent

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());
}
Also used : SpanData(io.opentelemetry.sdk.trace.data.SpanData) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) Test(org.junit.Test)

Example 37 with ServiceMetricEvent

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());
}
Also used : SpanData(io.opentelemetry.sdk.trace.data.SpanData) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) Test(org.junit.Test)

Example 38 with ServiceMetricEvent

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());
}
Also used : Emitter(org.apache.druid.java.util.emitter.core.Emitter) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) Test(org.junit.Test)

Example 39 with ServiceMetricEvent

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);
}
Also used : Emitter(org.apache.druid.java.util.emitter.core.Emitter) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) EasyMock.anyString(org.easymock.EasyMock.anyString) Test(org.junit.Test)

Example 40 with ServiceMetricEvent

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));
}
Also used : HashMap(java.util.HashMap) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

ServiceMetricEvent (org.apache.druid.java.util.emitter.service.ServiceMetricEvent)64 Test (org.junit.Test)56 DateTime (org.joda.time.DateTime)18 HashMap (java.util.HashMap)14 ServiceEventBuilder (org.apache.druid.java.util.emitter.service.ServiceEventBuilder)14 Emitter (org.apache.druid.java.util.emitter.core.Emitter)12 Event (org.apache.druid.java.util.emitter.core.Event)12 SpanData (io.opentelemetry.sdk.trace.data.SpanData)10 ImmutableMap (com.google.common.collect.ImmutableMap)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 File (java.io.File)4 FileOutputStream (java.io.FileOutputStream)4 OutputStream (java.io.OutputStream)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Parameters (junitparams.Parameters)4 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)4 AlertEvent (org.apache.druid.java.util.emitter.service.AlertEvent)4 ServiceEmitter (org.apache.druid.java.util.emitter.service.ServiceEmitter)4 ImmutableList (com.google.common.collect.ImmutableList)2