use of com.creditease.monitor.captureframework.spi.MonitorElement in project uavstack by uavorg.
the class StandardMonitor method doCapture.
@Override
public void doCapture(String captureId, CaptureContext context, CapturePhase capPhase) {
if (captureId == null) {
return;
}
// step 1: see if it is a valid captureId
MonitorElement[] elems = mr.getElementByCapId(captureId);
for (MonitorElement elem : elems) {
// if the monitor element is not enabled, just skip it
if (elem.isEnabled() == false)
continue;
// step 2: get capture class
String capClassName = elem.getCapClass();
// step 3: check if there is one handler exists, if not new one
MonitorElemCapHandler caphandler = selectHandler(capClassName);
// step 4: invoke handler
if (caphandler != null) {
try {
invokeCaphandler(context, capPhase, elem, caphandler);
} catch (Exception e) {
log.error("captureHandler[" + capClassName + "] execution [" + capPhase + "] fails ", e);
// ignore
}
}
}
}
use of com.creditease.monitor.captureframework.spi.MonitorElement in project uavstack by uavorg.
the class AbsDBPoolHookProxy method run.
@Override
public void run(HookContext context) {
String check = (String) context.get("monitor.client.prestore");
if (check == null) {
return;
}
/**
* Step 1: 从ClientMonitor去clientResp的MonitorElem
*/
Monitor monitor = MonitorFactory.instance().getMonitor(CaptureConstants.MONITOR_CLIENT);
MonitorElement[] meElem = monitor.getRepository().getElementByMoElemIdAndCapId(CaptureConstants.MOELEM_CLIENT_RESPTIME, CaptureConstants.CAPPOINT_APP_CLIENT);
MonitorElement clientElem = meElem[0];
collectDBPoolMetrics(clientElem);
}
use of com.creditease.monitor.captureframework.spi.MonitorElement in project uavstack by uavorg.
the class StandardMonitorRepository method getElementByCapId.
@Override
public MonitorElement[] getElementByCapId(String CaptureId) {
List<MonitorElement> list = new ArrayList<MonitorElement>();
Collection<MonitorElement> elems = elemsMap.values();
for (MonitorElement elem : elems) {
if (elem.getCaptureId().equals(CaptureId)) {
list.add(elem);
}
}
MonitorElement[] array = new MonitorElement[list.size()];
return list.toArray(array);
}
use of com.creditease.monitor.captureframework.spi.MonitorElement in project uavstack by uavorg.
the class StandardMonitorRepository method addElement.
@Override
public void addElement(String monitorElemId, String captureId, String capClass) {
if (captureId == null || monitorElemId == null || capClass == null) {
return;
}
String elemKey = monitorElemId + ":" + captureId + ":" + capClass;
MonitorElement elem = new StandardMonitorElement(monitorElemId, captureId, capClass, monitor);
elemsMap.put(elemKey, elem);
}
use of com.creditease.monitor.captureframework.spi.MonitorElement in project uavstack by uavorg.
the class StandardMonitorRepository method getElementByMoElemIdAndCapId.
@Override
public MonitorElement[] getElementByMoElemIdAndCapId(String moElemId, String captureId) {
List<MonitorElement> list = new ArrayList<MonitorElement>();
Collection<MonitorElement> elems = elemsMap.values();
for (MonitorElement elem : elems) {
if (elem.getCaptureId().equals(captureId) && elem.getMonitorElemId().equals(moElemId)) {
list.add(elem);
}
}
MonitorElement[] array = new MonitorElement[list.size()];
return list.toArray(array);
}
Aggregations