use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class HttpEmitterFactory method makeEmitter.
@Override
public Emitter makeEmitter(ObjectMapper objectMapper, AsyncHttpClient httpClient, Lifecycle lifecycle) {
Emitter retVal = new HttpPostEmitter(this, httpClient, objectMapper);
lifecycle.addManagedInstance(retVal);
return retVal;
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class NoopEmitterFactory method makeEmitter.
public Emitter makeEmitter(Lifecycle lifecycle) {
Emitter retVal = new NoopEmitter();
lifecycle.addManagedInstance(retVal);
return retVal;
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class ParametrizedUriEmitterFactory method makeEmitter.
@Override
public Emitter makeEmitter(ObjectMapper objectMapper, AsyncHttpClient httpClient, Lifecycle lifecycle) {
final Emitter retVal = new ParametrizedUriEmitter(this, httpClient, objectMapper);
lifecycle.addManagedInstance(retVal);
return retVal;
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class DropwizardEmitter method emit.
@Override
public void emit(Event event) {
synchronized (started) {
if (!started.get()) {
throw new RejectedExecutionException("Dropwizard emitter Service not started.");
}
}
if (event instanceof ServiceMetricEvent) {
ServiceMetricEvent metricEvent = (ServiceMetricEvent) event;
String host = metricEvent.getHost();
String service = metricEvent.getService();
String metric = metricEvent.getMetric();
Map<String, Object> userDims = metricEvent.getUserDims();
Number value = metricEvent.getValue();
ImmutableList.Builder<String> nameBuilder = new ImmutableList.Builder<>();
LinkedHashMap<String, String> dims = new LinkedHashMap<>();
final DropwizardMetricSpec metricSpec = converter.addFilteredUserDims(service, metric, userDims, dims);
if (metricSpec != null) {
if (config.getPrefix() != null) {
nameBuilder.add(config.getPrefix());
}
nameBuilder.add(StringUtils.format("metric=%s", metric));
nameBuilder.add(StringUtils.format("service=%s", service));
if (config.getIncludeHost()) {
nameBuilder.add(StringUtils.format("hostname=%s", host));
}
dims.forEach((key, value1) -> nameBuilder.add(StringUtils.format("%s=%s", key, value1)));
String fullName = StringUtils.replaceChar(Joiner.on(",").join(nameBuilder.build()), '/', ".");
updateMetric(fullName, value, metricSpec);
} else {
log.debug("Service=[%s], Metric=[%s] has no mapping", service, metric);
}
} else if (event instanceof AlertEvent) {
for (Emitter emitter : alertEmitters) {
emitter.emit(event);
}
} else {
throw new ISE("unknown event type [%s]", event.getClass());
}
}
use of org.apache.druid.java.util.emitter.core.Emitter in project druid by druid-io.
the class MockMemcachedClient method testMonitor.
@Test
public void testMonitor() throws Exception {
final MemcachedCache cache = MemcachedCache.create(memcachedCacheConfig);
final Emitter emitter = EasyMock.createNiceMock(Emitter.class);
final Collection<Event> events = new ArrayList<>();
final ServiceEmitter serviceEmitter = new ServiceEmitter("service", "host", emitter) {
@Override
public void emit(Event event) {
events.add(event);
}
};
while (events.isEmpty()) {
Thread.sleep(memcachedCacheConfig.getTimeout());
cache.doMonitor(serviceEmitter);
}
Assert.assertFalse(events.isEmpty());
ObjectMapper mapper = new DefaultObjectMapper();
for (Event event : events) {
log.debug("Found event `%s`", mapper.writeValueAsString(event.toMap()));
}
}
Aggregations