use of io.vertx.core.http.impl.HttpServerRequestImpl in project pinpoint by naver.
the class ServerConnectionHandleRequestInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
if (!hasScope(trace)) {
// not vertx trace.
return;
}
if (!leaveScope(trace)) {
if (logger.isInfoEnabled()) {
logger.info("Failed to leave scope. trace={}, sampled={}", trace, trace.canSampled());
}
// delete unstable trace.
deleteTrace(trace);
return;
}
if (!isEndScope(trace)) {
// ignored recursive call.
return;
}
if (!trace.canSampled()) {
deleteTrace(trace);
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
if (validate(args)) {
if (this.isTraceRequestParam) {
final HttpServerRequestImpl request = (HttpServerRequestImpl) args[0];
if (!excludeProfileMethodFilter.filter(request.method().toString())) {
final String parameters = getRequestParameter(request, 64, 512);
if (parameters != null && !parameters.isEmpty()) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
}
}
}
}
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", t.getMessage(), t);
}
} finally {
trace.traceBlockEnd();
deleteTrace(trace);
}
}
use of io.vertx.core.http.impl.HttpServerRequestImpl in project pinpoint by naver.
the class ServerConnectionHandleRequestInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
if (traceContext.currentRawTraceObject() != null) {
// duplicate trace.
return;
}
try {
if (!validate(args)) {
// invalid args.
return;
}
final HttpServerRequestImpl request = (HttpServerRequestImpl) args[0];
final HttpServerResponseImpl response = (HttpServerResponseImpl) args[1];
// create trace for standalone entry point.
final Trace trace = createTrace(request);
if (trace == null) {
return;
}
entryScope(trace);
if (!trace.canSampled()) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(VertxConstants.VERTX_HTTP_SERVER_INTERNAL);
// make asynchronous trace-id
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId(true);
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
((AsyncTraceIdAccessor) request)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
((AsyncTraceIdAccessor) response)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set closeable-asyncTraceId metadata {}", asyncTraceId);
}
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", t.getMessage(), t);
}
}
}
Aggregations