Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#noissue] Add debug log for reactor #9617

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ public void after(Object target, Object[] args, Object result, Throwable throwab

protected void setReactorContextToTarget(final AsyncContext asyncContext, final Object target) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set reactorContext to target. reactorContext={}", asyncContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
// Trace reactor
protected void setReactorContextToTarget(final AsyncContext asyncContext, final Object target) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set reactorContext to target. reactorContext={}", asyncContext);
}
}

// Trace subscribe() method
protected void setAsyncContextToTarget(AsyncContext asyncContext, Object target) {
AsyncContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set asyncContext to target. asyncContext={}", asyncContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ protected AsyncContext getAsyncContextFromArgs(final Object target, final Object

protected void setAsyncContextToTarget(AsyncContext asyncContext, Object target) {
AsyncContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set asyncContext to target. asyncContext={}", asyncContext);
}
}

// Trace reactor
protected void setReactorContextToTarget(AsyncContext asyncContext, Object target) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set reactorContext to target. reactorContext={}", asyncContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ boolean checkSubscriberReactorContextAccessor(final Object target, final Object[

protected void setReactorContextToTarget(AsyncContext asyncContext, Object target) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set reactorContext to target. reactorContext={}", asyncContext);
}
}

protected void setReactorContextToSubscriber(AsyncContext asyncContext, Object[] args) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, args, 0);
if (isDebug) {
logger.debug("Set reactorContext to args[0]. reactorContext={}", asyncContext);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ private boolean checkSubscriberReactorContextAccessor(final Object target, final

protected void setReactorContextToTarget(AsyncContext asyncContext, Object target) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
if (isDebug) {
logger.debug("Set reactorContext to target. reactorContext={}", asyncContext);
}
}

protected void setReactorContextToSubscriber(AsyncContext asyncContext, Object[] args) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, args, 0);
if (isDebug) {
logger.debug("Set reactorContext to args[0]. asyncContext={}", asyncContext);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,8 @@ boolean checkSubscriberReactorContextAccessor(final Object target, final Object[

protected void setReactorContextToResult(AsyncContext asyncContext, Object result) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, result);
if (isDebug) {
logger.debug("Set reactorContext to result. reactorContext={}", asyncContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ public void before(Object target, Object[] args) {
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);
}
logger.debug("Set asyncContext to args[0]. asyncContext={}", asyncContext);
}
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@
import com.navercorp.pinpoint.bootstrap.context.AsyncContext;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.logging.PLogger;
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;

import java.util.Objects;

/**
* @author jaehong.kim
*/
public class ChannelOperationsChannelMethodInterceptor implements AroundInterceptor {
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
private final boolean isDebug = logger.isDebugEnabled();

private final TraceContext traceContext;

Expand All @@ -48,6 +53,9 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(target);
if (asyncContext != null) {
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext to result. asyncContext={}", asyncContext);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContex
if (((ChannelOperations) target).receiveObject() instanceof AsyncContextAccessor) {
AsyncContextAccessor asyncContextAccessor = (AsyncContextAccessor) ((ChannelOperations) target).receiveObject();
asyncContextAccessor._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext to receiveObject. asyncContext={}", asyncContext);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] a
if (throwable == null && target instanceof AsyncContextAccessor) {
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext to target. asyncContext={}", asyncContext);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContex
// Set HttpClientOptions
if (args[0] instanceof AsyncContextAccessor) {
((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext to args[0]. asyncContext={}", asyncContext);
}
}
// Set hostname
if (args[0] instanceof ChannelOperations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] a
// Set MonoHttpConnect
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext to result. asyncContext={}", asyncContext);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
// Set AsyncContext to CoreSubscriber
if (result instanceof AsyncContextAccessor) {
((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(publisherAsyncContext);
if (isDebug) {
logger.debug("Set asyncContext to result. asyncContext={}", publisherAsyncContext);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] a
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext={} to result", asyncContext);
logger.debug("Set asyncContext to result. asyncContext={}", asyncContext);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void setAsyncContext(final AsyncContext asyncContext, final Object objec
if (object instanceof ReactorContextAccessor) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, object);
if (isDebug) {
logger.debug("Set reactorContext={} to arg", asyncContext);
logger.debug("Set reactorContext to args. reactorContext={}", asyncContext);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
final AsyncContext actualAsyncContext = ReactorContextAccessorUtils.findAsyncContext(args, 0);
if (actualAsyncContext != null) {
AsyncContextAccessorUtils.setAsyncContext(actualAsyncContext, target);
if (isDebug) {
logger.debug("Set asyncContext to target. asyncContext={}", actualAsyncContext);
}
ReactorContextAccessorUtils.setAsyncContext(actualAsyncContext, target);
if (isDebug) {
logger.debug("Set reactorContext to target. reactorContext={}", actualAsyncContext);
}
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ protected void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncCon
final AsyncContext publisherAsyncContext = AsyncContextAccessorUtils.getAsyncContext(target);
if (publisherAsyncContext != null) {
AsyncContextAccessorUtils.setAsyncContext(publisherAsyncContext, args, 0);
if (isDebug) {
logger.debug("Set asyncContext to target. asyncContext={}", publisherAsyncContext);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] a
// Avoid duplicate async context
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext to result. asyncContext={}", asyncContext);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
// Set result to asyncContext
if (throwable != null) {
AsyncContextAccessorUtils.setAsyncContext(asyncContext, result);
if (isDebug) {
logger.debug("Set asyncContext to result. asyncContext={}", asyncContext);
}
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ public void close() {
@Override
public String toString() {
return "DefaultAsyncContext{" +
"traceRoot=" + traceRoot +
", asyncId=" + asyncId +
"asyncId=" + asyncId +
", traceRoot=" + traceRoot +
'}';
}

}