/** * Sends a heartbeat event. */ public void run() { EventMonitor monitor = new EventMonitor("MonitoringEngineManager.lifecycle", MonitoringLevel.ESSENTIAL); monitor.set("eventType", "heartbeat"); monitor.fire(); } }
/** * Fire this event monitor. Delegates to AbstractMonitor.process(). */ public void fire() { process(); } }
private void fireJvmStat(final String type, final Long count, final Long time, final Double percent) { final EventMonitor monitor = new EventMonitor("JvmStats", MonitoringLevel.ESSENTIAL); monitor.set("type", type); if(count != null) { monitor.set("count", count); } if(time != null) { monitor.set("time", time); } if(percent != null) { monitor.set("percent", percent); } monitor.fire(); } }
private void fireMonitoringGapEvent(TransactionMonitor tMon, TransactionMonitor leftChild, TransactionMonitor rightChild, long latency) { EventMonitor eventMonitor = new EventMonitor("MonitoringCoverageGap"); eventMonitor.set("monitorName", tMon.get(Attribute.NAME)); eventMonitor.set("leftChild", leftChild == null ? null : leftChild.get(Attribute.NAME)); eventMonitor.set("rightChild", rightChild == null ? null : rightChild.get(Attribute.NAME)); eventMonitor.set(Attribute.LATENCY, latency); eventMonitor.fire(); }
/** * Method invoked when the given thread terminates due to the * given uncaught Throwable. * <p>Any exception thrown by this method will be ignored by the * Java Virtual Machine. * * @param thread the Thread * @param throwable the Throwable */ public void uncaughtException(Thread thread, Throwable throwable) { EventMonitor eventMonitor = new EventMonitor("ThreadTerminationDueToUncaughtThrowable"); eventMonitor.set("threadName", thread.getName()); eventMonitor.set("threadClass", thread.getClass().getName()); eventMonitor.set("stackTrace", getStackTrace(throwable)); eventMonitor.fire(); }
/** * Restarts the {@link MonitoringEngine} * @see MonitoringEngine#restart() */ public void reload() { EventMonitor monitor = new EventMonitor("MonitoringEngineManager.lifecycle", MonitoringLevel.ESSENTIAL); monitor.set("eventType", "reload"); monitor.fire(); MonitoringEngine.getInstance().restart(); }
/** * Implementaion of {@link java.lang.Runnable#run}. */ public void run() { final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); if(threadBean.isThreadContentionMonitoringEnabled()) { if(threadBean.findMonitorDeadlockedThreads() != null) { final EventMonitor monitor = new EventMonitor("JvmStats", MonitoringLevel.ESSENTIAL); monitor.set("type", "Thread.Deadlock"); monitor.set("count", 1); monitor.fire(); } } } }
/** * Stops all {@link #getTimerTasks() timer tasks} and {@link MonitoringEngine#shutdown() shuts the * monitoring engine down}. */ public void shutdown() { scheduledExecutor.shutdown(); EventMonitor monitor = new EventMonitor("MonitoringEngineManager.lifecycle", MonitoringLevel.ESSENTIAL); monitor.set("eventType", "shutdown"); monitor.fire(); MonitoringEngine.getInstance().shutdown(); }
/** * Sets all properties of the {@link MonitoringEngine} that have been configured, such as * {@link #getMonitoringEnabled()} and {@link #getInheritableStrategy()}, then starts it. After * the {@link MonitoringEngine} is started, schedules all {@link #getTimerTasks() timer tasks}. */ public void startup() { MonitoringEngine.getInstance().setMonitoringEnabled(monitoringEnabled); MonitoringEngine.getInstance().setProcessorFactory(factory); MonitoringEngine.getInstance().setDecomposer(decomposer); MonitoringEngine.getInstance().setInheritableStrategy(inheritableStrategy); MonitoringEngine.getInstance().setStartupRunnable(startupRunnable); if (timerTasks == null) { timerTasks = Collections.emptyMap(); } MonitoringEngine.getInstance().startup(); EventMonitor monitor = new EventMonitor("MonitoringEngineManager.lifecycle", MonitoringLevel.ESSENTIAL); monitor.set("eventType", "startup"); monitor.fire(); scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); for (Entry<Integer, Collection<TimerTask>> entry : timerTasks.entrySet()) { long millis = entry.getKey(); for (Runnable task : entry.getValue()) { scheduledExecutor.scheduleAtFixedRate(task, millis, millis, TimeUnit.MILLISECONDS); } } }