use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.
the class EmitterModule method getServiceEmitter.
@Provides
@ManageLifecycle
public ServiceEmitter getServiceEmitter(@Self Supplier<DruidNode> configSupplier, Emitter emitter, @ExtraServiceDimensions Map<String, String> extraServiceDimensions) {
final DruidNode config = configSupplier.get();
log.info("Using emitter [%s] for metrics and alerts, with dimensions [%s].", emitter, extraServiceDimensions);
final ServiceEmitter retVal = new ServiceEmitter(config.getServiceName(), config.getHostAndPortToUse(), emitter, ImmutableMap.copyOf(extraServiceDimensions));
EmittingLogger.registerEmitter(retVal);
return retVal;
}
use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.
the class KillSupervisorsCustomDuty method run.
@Override
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) {
long timestamp = System.currentTimeMillis() - retainDuration.getMillis();
try {
int supervisorRemoved = metadataSupervisorManager.removeTerminatedSupervisorsOlderThan(timestamp);
ServiceEmitter emitter = params.getEmitter();
emitter.emit(new ServiceMetricEvent.Builder().build("metadata/kill/supervisor/count", supervisorRemoved));
log.info("Finished running KillSupervisors duty. Removed %,d supervisor specs", supervisorRemoved);
} catch (Exception e) {
log.error(e, "Failed to kill terminated supervisor metadata");
}
return params;
}
use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.
the class BackgroundCachePopulatorTest method before.
@Before
public void before() {
this.backgroundCachePopulator = new BackgroundCachePopulator(Execs.multiThreaded(2, "CachingQueryRunnerTest-%d"), JSON_MAPPER, new CachePopulatorStats(), -1);
TopNQueryBuilder builder = new TopNQueryBuilder().dataSource("ds").dimension("top_dim").metric("imps").threshold(3).intervals("2011-01-05/2011-01-10").aggregators(AGGS).granularity(Granularities.ALL);
this.query = builder.build();
this.toolchest = new TopNQueryQueryToolChest(new TopNQueryConfig());
List<Result> expectedRes = makeTopNResults(false, OBJECTS);
this.closable = new AssertingClosable();
final Sequence resultSeq = Sequences.wrap(Sequences.simple(expectedRes), new SequenceWrapper() {
@Override
public void before() {
Assert.assertFalse(closable.isClosed());
}
@Override
public void after(boolean isDone, Throwable thrown) {
closable.close();
}
});
this.baseRunner = (queryPlus, responseContext) -> resultSeq;
this.cache = new Cache() {
private final ConcurrentMap<NamedKey, byte[]> baseMap = new ConcurrentHashMap<>();
@Override
public byte[] get(NamedKey key) {
return baseMap.get(key);
}
@Override
public void put(NamedKey key, byte[] value) {
baseMap.put(key, value);
}
@Override
public Map<NamedKey, byte[]> getBulk(Iterable<NamedKey> keys) {
return null;
}
@Override
public void close(String namespace) {
}
@Override
public void close() {
}
@Override
public CacheStats getStats() {
return null;
}
@Override
public boolean isLocal() {
return true;
}
@Override
public void doMonitor(ServiceEmitter emitter) {
}
};
}
use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.
the class LookupCoordinatorManagerTest method setUpStatic.
@BeforeClass
public static void setUpStatic() {
LoggingEmitter loggingEmitter = EasyMock.createNiceMock(LoggingEmitter.class);
EasyMock.replay(loggingEmitter);
SERVICE_EMITTER = new ServiceEmitter("", "", loggingEmitter) {
@Override
public void emit(Event event) {
EVENT_EMITS.incrementAndGet();
super.emit(event);
}
};
EmittingLogger.registerEmitter(SERVICE_EMITTER);
}
use of org.apache.druid.java.util.emitter.service.ServiceEmitter in project druid by druid-io.
the class JettyServerModuleTest method testJettyServerModule.
@Test
public void testJettyServerModule() {
List<Event> events = new ArrayList<>();
ServiceEmitter serviceEmitter = new ServiceEmitter("service", "host", Mockito.mock(Emitter.class)) {
@Override
public void emit(Event event) {
events.add(event);
}
};
QueuedThreadPool jettyServerThreadPool = Mockito.mock(QueuedThreadPool.class);
JettyServerModule.setJettyServerThreadPool(jettyServerThreadPool);
Mockito.when(jettyServerThreadPool.getThreads()).thenReturn(100);
Mockito.when(jettyServerThreadPool.getIdleThreads()).thenReturn(40);
Mockito.when(jettyServerThreadPool.isLowOnThreads()).thenReturn(true);
Mockito.when(jettyServerThreadPool.getMinThreads()).thenReturn(30);
Mockito.when(jettyServerThreadPool.getMaxThreads()).thenReturn(100);
Mockito.when(jettyServerThreadPool.getQueueSize()).thenReturn(50);
Mockito.when(jettyServerThreadPool.getBusyThreads()).thenReturn(60);
JettyServerModule.JettyMonitor jettyMonitor = new JettyServerModule.JettyMonitor("ds", "t0");
jettyMonitor.doMonitor(serviceEmitter);
Assert.assertEquals(8, events.size());
List<Pair<String, Number>> expectedEvents = Arrays.asList(new Pair<>("jetty/numOpenConnections", 0), new Pair<>("jetty/threadPool/total", 100), new Pair<>("jetty/threadPool/idle", 40), new Pair<>("jetty/threadPool/isLowOnThreads", 1), new Pair<>("jetty/threadPool/min", 30), new Pair<>("jetty/threadPool/max", 100), new Pair<>("jetty/threadPool/queueSize", 50), new Pair<>("jetty/threadPool/busy", 60));
for (int i = 0; i < expectedEvents.size(); i++) {
Pair<String, Number> expected = expectedEvents.get(i);
ServiceMetricEvent actual = (ServiceMetricEvent) (events.get(i));
Assert.assertEquals(expected.lhs, actual.getMetric());
Assert.assertEquals(expected.rhs, actual.getValue());
}
}
Aggregations