Search in sources :

Example 1 with MonitorElement

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
            }
        }
    }
}
Also used : MonitorElemCapHandler(com.creditease.monitor.captureframework.spi.MonitorElemCapHandler) MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Example 2 with MonitorElement

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);
}
Also used : Monitor(com.creditease.monitor.captureframework.spi.Monitor) MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Example 3 with MonitorElement

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);
}
Also used : ArrayList(java.util.ArrayList) MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Example 4 with MonitorElement

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);
}
Also used : MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Example 5 with MonitorElement

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);
}
Also used : ArrayList(java.util.ArrayList) MonitorElement(com.creditease.monitor.captureframework.spi.MonitorElement)

Aggregations

MonitorElement (com.creditease.monitor.captureframework.spi.MonitorElement)6 MonitorElemCapHandler (com.creditease.monitor.captureframework.spi.MonitorElemCapHandler)2 ArrayList (java.util.ArrayList)2 StandardMonitorRepository (com.creditease.monitor.captureframework.repository.StandardMonitorRepository)1 Monitor (com.creditease.monitor.captureframework.spi.Monitor)1 MonitorElementInstance (com.creditease.monitor.captureframework.spi.MonitorElementInstance)1 MonitorRepository (com.creditease.monitor.captureframework.spi.MonitorRepository)1