use of com.creditease.monitor.log.DataLogger in project uavstack by uavorg.
the class ClientSpanInvokeChainHandler method doCap.
/**
* Finish Span and Logger the Span Metrics
*/
@Override
public void doCap(InvokeChainContext context) {
String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);
// in the same thread
Span span = this.spanFactory.getRemoveSpanFromContext(storeKey);
if (span == null) {
// in async thread
span = (Span) context.get(InvokeChainConstants.PARAM_SPAN_KEY);
}
if (span == null) {
return;
}
context.put(InvokeChainConstants.PARAM_SPAN_KEY, span);
String appid = (String) context.get(CaptureConstants.INFO_CLIENT_APPID);
if (appid == null) {
return;
}
span.end();
span.setAppid(appid);
String responseState = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE);
span.setState(context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE).toString(), responseState);
DataLogger invokeChainLogger = this.getAppInvokeChainLogger(appid);
String spanLog = span.toString();
invokeChainLogger.logData(spanLog);
if (logger.isDebugable()) {
logger.debug("doCap:span=" + spanLog, null);
}
}
use of com.creditease.monitor.log.DataLogger in project uavstack by uavorg.
the class MethodSpanInvokeChainHandler method doCap.
@Override
public void doCap(InvokeChainContext context) {
String storeKey = (String) context.get(InvokeChainConstants.METHOD_SPAN_STOREKEY);
if (storeKey == null) {
return;
}
Span span = (Span) context.get(storeKey);
if (span == null) {
return;
}
String appid = (String) context.get(InvokeChainConstants.METHOD_SPAN_APPID);
if (appid == null) {
return;
}
span.end();
span.setAppid(appid);
String responseState = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE);
span.setState(context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE).toString(), responseState);
DataLogger invokeChainLogger = this.getAppInvokeChainLogger(appid);
String spanLog = span.toString();
invokeChainLogger.logData(spanLog);
if (logger.isDebugable()) {
logger.debug("doCap:span=" + spanLog, null);
}
}
use of com.creditease.monitor.log.DataLogger in project uavstack by uavorg.
the class ServiceSpanInvokeChainHandler method doCap.
/**
* Finish Span and Logger the Span metrics
*/
@Override
public void doCap(InvokeChainContext context) {
/**
* Step 1: try to get service span,
*/
// 移除main,防止uav没有劫持到的请求发生调用链连接现象
this.spanFactory.getRemoveSpanFromContext("main");
String url = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
Span span;
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
span = this.spanFactory.getSpanFromContext(url);
} else {
span = this.spanFactory.getRemoveSpanFromContext(url);
}
if (span == null) {
return;
}
String appid = null;
if (context.get(CaptureConstants.INFO_CLIENT_APPID) != null && !StringHelper.isEmpty(context.get(CaptureConstants.INFO_CLIENT_APPID).toString())) {
appid = (String) context.get(CaptureConstants.INFO_CLIENT_APPID);
span.setClassName(context.get(InvokeChainConstants.CLIENT_IT_CLASS).toString());
span.setMethodName(context.get(InvokeChainConstants.CLIENT_IT_METHOD).toString());
String responseState = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE);
span.setState(context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE).toString(), responseState);
} else if (context.get(CaptureConstants.INFO_APPSERVER_APPID) != null && !StringHelper.isEmpty(context.get(CaptureConstants.INFO_APPSERVER_APPID).toString())) {
appid = (String) context.get(CaptureConstants.INFO_APPSERVER_APPID);
span.setClassName(context.get(InvokeChainConstants.CLIENT_IT_CLASS).toString());
span.setMethodName(context.get(InvokeChainConstants.CLIENT_IT_METHOD).toString());
String responseState = (String) context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE);
span.setState(context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE).toString(), responseState);
} else {
String appContext = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT);
String realpath = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH);
if (null == appContext && null == realpath) {
return;
}
appid = MonitorServerUtil.getApplicationId(appContext, realpath);
if (appid == null) {
return;
}
/**
* match service class & method
*/
ProfileServiceMapMgr smgr = (ProfileServiceMapMgr) UAVServer.instance().getServerInfo("profile.servicemapmgr");
ServiceMapBinding smb = smgr.searchServiceMapBinding(appid, url);
if (smb != null) {
span.setClassName(smb.getClazz());
if (StringHelper.isEmpty(span.getMethodName())) {
span.setMethodName(smb.getMethod());
}
}
span.setState(context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE).toString(), null);
}
context.put(CaptureConstants.INFO_APPSERVER_APPID, appid);
/**
* Step 2: end span
*/
span.end();
/**
* Step 3: set service span info
*/
span.setAppid(appid);
span.setUrl(url);
String spanLog = span.toString();
if (logger.isDebugable()) {
logger.debug("doCap:span=" + spanLog, null);
}
/**
* Step 3: get the related invokechain logger of this application to record span
*/
DataLogger invokeChainLogger = this.getAppInvokeChainLogger(appid);
if (invokeChainLogger == null) {
return;
}
invokeChainLogger.logData(spanLog);
}
use of com.creditease.monitor.log.DataLogger in project uavstack by uavorg.
the class MQSlowOperHandler method doCap.
@Override
public void doCap(InvokeChainContext context, Object[] args) {
Span span = (Span) args[0];
DataLogger invokeChainLogger = this.getAppInvokeChainLogger(span.getAppid());
if (invokeChainLogger == null) {
return;
}
SlowOperSpan slowOperSpan = this.spanFactory.getRemoveSlowOperSpanFromContext(this.getSlowOperSpanKey(span));
if (slowOperSpan == null) {
return;
}
invokeChainLogger.logData(slowOperSpan.toString());
}
use of com.creditease.monitor.log.DataLogger in project uavstack by uavorg.
the class UEMServiceGFHandler method logData.
private void logData(String appid, String data) {
DataLogger dl = this.getSupporter(UEMSupporter.class).getDataLogger("uem", appid);
if (dl == null) {
return;
}
dl.logData(data);
}
Aggregations