Search in sources :

Example 1 with AsyncStartFlagFieldAccessor

use of com.navercorp.pinpoint.plugin.netty.field.accessor.AsyncStartFlagFieldAccessor in project pinpoint by naver.

the class HttpEncoderInterceptor method validate.

private boolean validate(Object[] args) {
    if (ArrayUtils.getLength(args) != 3) {
        return false;
    }
    if (!(args[0] instanceof ChannelHandlerContext)) {
        return false;
    }
    ChannelHandlerContext channelHandlerContext = (ChannelHandlerContext) args[0];
    Channel channel = channelHandlerContext.channel();
    if (channel == null) {
        return false;
    }
    if (!(args[1] instanceof HttpMessage)) {
        return false;
    }
    HttpMessage httpMessage = (HttpMessage) args[1];
    if (httpMessage.headers() == null) {
        return false;
    }
    if (!(args[1] instanceof AsyncContextAccessor)) {
        return false;
    }
    if (!(args[1] instanceof AsyncStartFlagFieldAccessor)) {
        return false;
    }
    return true;
}
Also used : Channel(io.netty.channel.Channel) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) HttpMessage(io.netty.handler.codec.http.HttpMessage) AsyncStartFlagFieldAccessor(com.navercorp.pinpoint.plugin.netty.field.accessor.AsyncStartFlagFieldAccessor)

Example 2 with AsyncStartFlagFieldAccessor

use of com.navercorp.pinpoint.plugin.netty.field.accessor.AsyncStartFlagFieldAccessor in project pinpoint by naver.

the class HttpEncoderInterceptor method beforeAsync.

private void beforeAsync(Object target, Object[] args) {
    ((AsyncStartFlagFieldAccessor) args[1])._$PINPOINT$_setAsyncStartFlag(true);
    final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 1);
    if (asyncContext == null) {
        logger.debug("AsyncContext not found");
        return;
    }
    final Trace trace = getAsyncTrace(asyncContext);
    if (trace == null) {
        return;
    }
    // entry scope.
    entryAsyncTraceScope(trace);
    try {
        // trace event for default & async.
        final SpanEventRecorder recorder = trace.traceBlockBegin();
        doInBeforeTrace(recorder, trace, target, args);
    } catch (Throwable th) {
        if (logger.isWarnEnabled()) {
            logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext) AsyncStartFlagFieldAccessor(com.navercorp.pinpoint.plugin.netty.field.accessor.AsyncStartFlagFieldAccessor)

Aggregations

AsyncStartFlagFieldAccessor (com.navercorp.pinpoint.plugin.netty.field.accessor.AsyncStartFlagFieldAccessor)2 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)1 AsyncContext (com.navercorp.pinpoint.bootstrap.context.AsyncContext)1 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 Channel (io.netty.channel.Channel)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 HttpMessage (io.netty.handler.codec.http.HttpMessage)1