Search in sources :

Example 6 with AsyncState

use of com.navercorp.pinpoint.bootstrap.context.AsyncState in project pinpoint by naver.

the class AsyncContextSpanEventEndPointInterceptor method finishAsyncState.

private void finishAsyncState(final AsyncContext asyncContext) {
    if (asyncContext instanceof AsyncStateSupport) {
        final AsyncStateSupport asyncStateSupport = (AsyncStateSupport) asyncContext;
        AsyncState asyncState = asyncStateSupport.getAsyncState();
        asyncState.finish();
        if (isDebug) {
            logger.debug("finished asyncState. asyncTraceId={}", asyncContext);
        }
    }
}
Also used : AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) AsyncStateSupport(com.navercorp.pinpoint.bootstrap.context.AsyncStateSupport)

Example 7 with AsyncState

use of com.navercorp.pinpoint.bootstrap.context.AsyncState in project pinpoint by naver.

the class ServerHalfCloseListenerInterceptor method finishAsyncState.

@Override
protected void finishAsyncState(final AsyncContext asyncContext) {
    if (asyncContext instanceof AsyncStateSupport) {
        final AsyncStateSupport asyncStateSupport = (AsyncStateSupport) asyncContext;
        AsyncState asyncState = asyncStateSupport.getAsyncState();
        asyncState.finish();
        if (isDebug) {
            logger.debug("finished asyncState. asyncTraceId={}", asyncContext);
        }
    }
}
Also used : AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) AsyncStateSupport(com.navercorp.pinpoint.bootstrap.context.AsyncStateSupport)

Example 8 with AsyncState

use of com.navercorp.pinpoint.bootstrap.context.AsyncState in project pinpoint by naver.

the class AbstractHttpServerHandleInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    if (traceContext.currentRawTraceObject() != null) {
        if (isDisconnecting(args)) {
            final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 0);
            if (asyncContext != null) {
                if (asyncContext instanceof AsyncStateSupport) {
                    final AsyncStateSupport asyncStateSupport = (AsyncStateSupport) asyncContext;
                    AsyncState asyncState = asyncStateSupport.getAsyncState();
                    asyncState.finish();
                    if (isDebug) {
                        logger.debug("Finished asyncState. asyncTraceId={}", asyncContext);
                    }
                }
            }
        }
        // duplicate trace.
        return;
    }
    try {
        if (Boolean.FALSE == isReceived(args)) {
            // invalid args
            return;
        }
        final HttpServerRequest request = (HttpServerRequest) args[0];
        final HttpServerResponse response = (HttpServerResponse) args[0];
        this.servletRequestListener.initialized(request, ReactorNettyConstants.REACTOR_NETTY_INTERNAL, this.methodDescriptor);
        // must after request listener due to trace block begin
        this.servletResponseListener.initialized(response, ReactorNettyConstants.REACTOR_NETTY_INTERNAL, this.methodDescriptor);
        // Set end-point
        final Trace trace = this.traceContext.currentTraceObject();
        if (trace == null) {
            return;
        }
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        if (recorder != null) {
            // make asynchronous trace-id
            final boolean asyncStateSupport = enableAsyncEndPoint;
            final AsyncContext asyncContext = recorder.recordNextAsyncContext(asyncStateSupport);
            ((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
            if (isDebug) {
                if (enableAsyncEndPoint) {
                    logger.debug("Set closeable-AsyncContext {}", asyncContext);
                } else {
                    logger.debug("Set AsyncContext {}", asyncContext);
                }
            }
        }
    } catch (Throwable t) {
        if (isInfo) {
            logger.info("Failed to servlet request event handle.", t);
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) HttpServerRequest(reactor.netty.http.server.HttpServerRequest) HttpServerResponse(reactor.netty.http.server.HttpServerResponse) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext) AsyncStateSupport(com.navercorp.pinpoint.bootstrap.context.AsyncStateSupport)

Example 9 with AsyncState

use of com.navercorp.pinpoint.bootstrap.context.AsyncState in project pinpoint by naver.

the class DefaultBaseTraceFactory method continueAsyncTraceObject.

// entry point async trace.
@InterfaceAudience.LimitedPrivate("vert.x")
@Override
public Trace continueAsyncTraceObject(final TraceId traceId) {
    final TraceSampler.State state = traceSampler.isContinueSampled();
    final boolean sampling = state.isSampled();
    if (sampling) {
        final TraceRoot traceRoot = traceRootFactory.continueTraceRoot(traceId, state.nextId());
        final Span span = spanFactory.newSpan(traceRoot);
        final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
        final SpanAsyncStateListener asyncStateListener = new SpanAsyncStateListener(span, storageFactory);
        final AsyncState asyncState = new ListenableAsyncState(asyncStateListener, handle);
        final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), sampling);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot, asyncState);
        final DefaultTrace trace = new DefaultTrace(span, callStack, storage, sampling, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
        final AsyncTrace asyncTrace = new AsyncTrace(traceRoot, trace, asyncState);
        return asyncTrace;
    } else {
        return newDisableTrace(state.nextId());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Example 10 with AsyncState

use of com.navercorp.pinpoint.bootstrap.context.AsyncState in project pinpoint by naver.

the class DefaultBaseTraceFactory method newAsyncTraceObject.

// entry point async trace.
@InterfaceAudience.LimitedPrivate("vert.x")
@Override
public Trace newAsyncTraceObject() {
    final TraceSampler.State state = traceSampler.isNewSampled();
    final boolean sampling = state.isSampled();
    if (sampling) {
        final TraceRoot traceRoot = traceRootFactory.newTraceRoot(state.nextId());
        final Span span = spanFactory.newSpan(traceRoot);
        final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
        final SpanAsyncStateListener asyncStateListener = new SpanAsyncStateListener(span, storageFactory);
        final AsyncState asyncState = new ListenableAsyncState(asyncStateListener, handle);
        final TraceId traceId = traceRoot.getTraceId();
        final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), sampling);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot, asyncState);
        final DefaultTrace trace = new DefaultTrace(span, callStack, storage, sampling, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
        final AsyncTrace asyncTrace = new AsyncTrace(traceRoot, trace, asyncState);
        return asyncTrace;
    } else {
        return newDisableTrace(state.nextId());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Aggregations

AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)10 AsyncStateSupport (com.navercorp.pinpoint.bootstrap.context.AsyncStateSupport)7 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)3 AsyncContext (com.navercorp.pinpoint.bootstrap.context.AsyncContext)2 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)2 TraceSampler (com.navercorp.pinpoint.bootstrap.sampler.TraceSampler)2 ActiveTraceHandle (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle)2 ListenableAsyncState (com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState)2 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)2 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)2 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)1 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 AsyncId (com.navercorp.pinpoint.profiler.context.AsyncId)1 HttpServerRequest (reactor.netty.http.server.HttpServerRequest)1 HttpServerResponse (reactor.netty.http.server.HttpServerResponse)1