use of com.creditease.monitor.captureframework.spi.Monitor in project uavstack by uavorg.
the class AppCustomMonitor method doGet.
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest request,
* javax.servlet.http.HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/**
* get your defined application monitor
*/
Monitor monitor = MonitorFactory.instance().getMonitor("AppCustomMonitor");
/**
* create CaptureContext to wrap anything wish to pass MyAppMonitorCounterHandler
*/
CaptureContext context = monitor.getCaptureContext();
context.put(HttpServletRequest.class, request);
context.put(HttpServletResponse.class, response);
/**
* do DOCAP operation, then MyAppMonitorCounterHandler is notified to do the same operation
*/
monitor.doCapture("AppCustomMonitor.doGet", context, CapturePhase.DOCAP);
request.getSession().setAttribute("test", 1);
}
use of com.creditease.monitor.captureframework.spi.Monitor 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.Monitor in project uavstack by uavorg.
the class UAVServer method runMonitorAsyncCaptureOnServerCapPoint.
/**
* runMonitorAsyncCaptureOnServerCapPoint
*
* @param captureId
* @param phase
* @param contextParams
* @param CaptureContextMapFromAnotherThread
* @return
*/
public Map<String, CaptureContext> runMonitorAsyncCaptureOnServerCapPoint(String captureId, CapturePhase phase, Map<String, Object> contextParams, Map<String, CaptureContext> CaptureContextMapFromAnotherThread) {
long st = System.currentTimeMillis();
Map<String, CaptureContext> curCaptureContextMap = new HashMap<String, CaptureContext>();
Monitor[] monitors = MonitorFactory.instance().getServerCapPointBindMonitors(captureId, phase);
if (monitors == null || monitors.length == 0) {
return curCaptureContextMap;
}
for (Monitor monitor : monitors) {
CaptureContext context = monitor.getCaptureContext();
/**
* if CaptureContextMapFromAnotherThread exists, need merge CaptureContext first
*/
if (CaptureContextMapFromAnotherThread != null) {
CaptureContext anotherCC = CaptureContextMapFromAnotherThread.get(monitor.getId());
if (anotherCC != null) {
context.put(anotherCC.getAll());
}
}
if (contextParams != null) {
context.put(contextParams);
}
// tmp store CaptureContext
curCaptureContextMap.put(monitor.getId(), context);
monitor.doCapture(captureId, context, phase);
// release capture context when PRECAP or DOCAP is done
monitor.releaseCaptureContext();
}
if (this.monitor != null) {
this.monitor.logPerf(st, "");
}
return curCaptureContextMap;
}
use of com.creditease.monitor.captureframework.spi.Monitor in project uavstack by uavorg.
the class UAVServer method runMonitorCaptureOnServerCapPoint.
/**
* runMonitorCaptureOnServerCapPoint
*
* @param captureId
* @param phase
* @param contextParams
*/
public void runMonitorCaptureOnServerCapPoint(String captureId, CapturePhase phase, Map<String, Object> contextParams) {
long st = System.currentTimeMillis();
Monitor[] monitors = MonitorFactory.instance().getServerCapPointBindMonitors(captureId, phase);
if (monitors == null || monitors.length == 0) {
return;
}
String contextTag = null;
if (contextParams != null) {
contextTag = (String) contextParams.get(CaptureConstants.INFO_CAPCONTEXT_TAG);
}
for (Monitor monitor : monitors) {
CaptureContext context = null;
if (null == contextTag) {
context = monitor.getCaptureContext();
} else {
context = monitor.getCaptureContext(contextTag);
}
if (contextParams != null) {
context.put(contextParams);
}
monitor.doCapture(captureId, context, phase);
// release capture context when DOCAP is done
if (phase == CapturePhase.DOCAP) {
if (null == contextTag) {
monitor.releaseCaptureContext();
} else {
monitor.releaseCaptureContext(contextTag);
}
}
}
if (this.monitor != null) {
this.monitor.logPerf(st, "");
}
}
Aggregations