Search in sources :

Example 1 with HttpServerResponseImpl

use of io.vertx.core.http.impl.HttpServerResponseImpl 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);
        }
    }
}
Also used : HttpServerResponseImpl(io.vertx.core.http.impl.HttpServerResponseImpl) HttpServerRequestImpl(io.vertx.core.http.impl.HttpServerRequestImpl) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)

Aggregations

AsyncTraceIdAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)1 HttpServerRequestImpl (io.vertx.core.http.impl.HttpServerRequestImpl)1 HttpServerResponseImpl (io.vertx.core.http.impl.HttpServerResponseImpl)1