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);
}
}
}
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);
}
}
}
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);
}
}
}
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());
}
}
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());
}
}
Aggregations