use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class HttpMethodBaseExecuteMethodInterceptor method recordEntity.
private void recordEntity(HttpMethod httpMethod, Trace trace) {
if (httpMethod instanceof EntityEnclosingMethod) {
final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) httpMethod;
final RequestEntity entity = entityEnclosingMethod.getRequestEntity();
if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) {
if (entitySampler.isSampling()) {
try {
String entityValue;
String charSet = entityEnclosingMethod.getRequestCharSet();
if (charSet == null || charSet.isEmpty()) {
charSet = HttpConstants.DEFAULT_CONTENT_CHARSET;
}
if (entity instanceof ByteArrayRequestEntity || entity instanceof StringRequestEntity) {
entityValue = entityUtilsToString(entity, charSet);
} else {
entityValue = entity.getClass() + " (ContentType:" + entity.getContentType() + ")";
}
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, entityValue);
} 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 HttpMethodBaseExecuteMethodInterceptor method recordCookie.
private void recordCookie(HttpMethod httpMethod, Trace trace) {
org.apache.commons.httpclient.Header cookie = httpMethod.getRequestHeader("Cookie");
if (cookie == null) {
return;
}
final String value = cookie.getValue();
if (value != null && !value.isEmpty()) {
if (cookieSampler.isSampling()) {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.abbreviate(value, MAX_READ_SIZE));
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class HttpRequestExecuteAsyncMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
// set asynchronous trace
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
// set async id.
InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
if (transaction != null) {
transaction.setAttachment(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
} catch (Throwable t) {
logger.warn("Failed to before process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class ToJsonInterceptor method after.
@Override
public void after(Object target, Object result, Throwable throwable) {
if (logger.isDebugEnabled()) {
logger.afterInterceptor(target, null, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordServiceType(GsonPlugin.GSON_SERVICE_TYPE);
recorder.recordApi(descriptor);
recorder.recordException(throwable);
if (result != null && result instanceof String) {
recorder.recordAttribute(GsonPlugin.GSON_ANNOTATION_KEY_JSON_LENGTH, ((String) result).length());
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class StandardHostValveInvokeInterceptor method before.
/*
* (non-Javadoc)
*
* @see com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor#before(java.lang.Object, java.lang.Object[])
*/
@Override
public void before(final Object target, final Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
final Trace trace = createTrace(target, args);
if (trace == null) {
return;
}
// TODO STATDISABLE this logic was added to disable statistics tracing
if (!trace.canSampled()) {
return;
}
// ------------------------------------------------------
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(JbossConstants.JBOSS_METHOD);
} catch (final Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
Aggregations