use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class HttpRequestExecutorExecuteMethodInterceptor method recordEntity.
protected void recordEntity(HttpMessage httpMessage, Trace trace) {
if (httpMessage instanceof HttpEntityEnclosingRequest) {
final HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) httpMessage;
try {
final HttpEntity entity = entityRequest.getEntity();
if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) {
if (entitySampler.isSampling()) {
final String entityString = entityUtilsToString(entity, "UTF8", 1024);
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, entityString);
}
}
} catch (Exception e) {
logger.debug("HttpEntityEnclosingRequest entity record fail. Caused:{}", e.getMessage(), e);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class CassandraStatementExecuteQueryInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
if (databaseInfo == null) {
databaseInfo = UnKnownDatabaseInfo.INSTANCE;
}
recorder.recordServiceType(databaseInfo.getExecuteQueryType());
recorder.recordEndPoint(databaseInfo.getMultipleHost());
recorder.recordDestinationId(databaseInfo.getDatabaseId());
String sql;
if (args[0] instanceof BoundStatement) {
sql = ((BoundStatement) args[0]).preparedStatement().getQueryString();
} else if (args[0] instanceof RegularStatement) {
sql = ((RegularStatement) args[0]).getQueryString();
} else {
// we have string
sql = (String) args[0];
}
ParsingResult parsingResult = traceContext.parseSql(sql);
if (parsingResult != null) {
((ParsingResultAccessor) target)._$PINPOINT$_setParsingResult(parsingResult);
} else {
if (logger.isErrorEnabled()) {
logger.error("sqlParsing fail. parsingResult is null sql:{}", sql);
}
}
Map<Integer, String> bindValue = ((BindValueAccessor) target)._$PINPOINT$_getBindValue();
// Extracting bind variables from already-serialized is too risky
if (bindValue != null && !bindValue.isEmpty()) {
String bindString = toBindVariable(bindValue);
recorder.recordSqlParsingResult(parsingResult, bindString);
} else {
recorder.recordSqlParsingResult(parsingResult);
}
recorder.recordApi(descriptor);
clean(target);
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn(e.getMessage(), e);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class CxfClientInvokeSyncMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
if (!trace.canSampled()) {
if (isDebug) {
logger.debug("Sampling is disabled");
}
return;
}
String endpoint = getDestination(args);
String operation = getOperation(args);
Object[] parameters = getParameters(operation, args);
SpanEventRecorder recorder = trace.traceBlockBegin();
TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(CxfPluginConstants.CXF_CLIENT_SERVICE_TYPE);
recorder.recordDestinationId(endpoint);
recorder.recordAttribute(CxfPluginConstants.CXF_OPERATION, operation);
recorder.recordAttribute(CxfPluginConstants.CXF_ARGS, Arrays.toString(parameters));
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class DefaultClientExchangeHandlerImplStartMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
final HttpRequest httpRequest = getHttpRequest(target);
if (httpRequest != null) {
// Accessing httpRequest here not BEFORE() because it can cause side effect.
if (httpRequest.getRequestLine() != null) {
final String httpUrl = InterceptorUtils.getHttpUrl(httpRequest.getRequestLine().getUri(), param);
recorder.recordAttribute(AnnotationKey.HTTP_URL, httpUrl);
}
final NameIntValuePair<String> host = getHost(target);
if (host != null) {
final String endpoint = getEndpoint(host.getName(), host.getValue());
recorder.recordDestinationId(endpoint);
}
recordHttpRequest(recorder, httpRequest, throwable);
}
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class DefaultHttpRequestRetryHandlerRetryRequestMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
// arguments(final IOException exception, final int executionCount, final HttpContext context)
final StringBuilder sb = new StringBuilder();
if (args != null && args.length >= 1 && args[0] != null && args[0] instanceof Exception) {
sb.append(args[0].getClass().getName()).append(", ");
}
if (args != null && args.length >= 2 && args[1] != null && args[1] instanceof Integer) {
sb.append(args[1]);
}
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, sb.toString());
if (result != null) {
recorder.recordAttribute(AnnotationKey.RETURN_DATA, result);
}
} finally {
trace.traceBlockEnd();
}
}
Aggregations