Search in sources :

Example 1 with RequestContextImpl

use of akka.http.scaladsl.server.RequestContextImpl in project pinpoint by naver.

the class DirectivesInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    int requestContextIndex = getArgsIndexOfRequestContext(args);
    if (requestContextIndex == -1) {
        return;
    }
    if (traceContext.currentTraceObject() != null) {
        return;
    }
    RequestContextImpl requestContext = (RequestContextImpl) args[requestContextIndex];
    if (!(requestContext instanceof AsyncContextAccessor)) {
        if (isDebug) {
            logger.debug("Invalid requestContext. Need metadata accessor({}).", AsyncContextAccessor.class.getName());
        }
        return;
    }
    akka.http.scaladsl.model.HttpRequest request = requestContext.request();
    final Trace trace = createTrace(request);
    if (trace == null || !trace.canSampled()) {
        return;
    }
    final SpanEventRecorder recorder = trace.traceBlockBegin();
    recorder.recordServiceType(AkkaHttpConstants.AKKA_HTTP_SERVER_INTERNAL);
    final AsyncContext asyncContext = recorder.recordNextAsyncContext(true);
    ((AsyncContextAccessor) requestContext)._$PINPOINT$_setAsyncContext(asyncContext);
    if (isDebug) {
        logger.debug("Set closeable-AsyncContext {}", asyncContext);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) RequestContextImpl(akka.http.scaladsl.server.RequestContextImpl) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Aggregations

RequestContextImpl (akka.http.scaladsl.server.RequestContextImpl)1 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