コード例 #1
0
  @Override
  public void before(Object target, Object[] args) {
    if (isDebug) {
      logger.beforeInterceptor(target, args);
    }

    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
      return;
    }

    SpanEventRecorder recorder = trace.traceBlockBegin();
    try {
      // set asynchronous trace
      final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
      recorder.recordNextAsyncId(asyncTraceId.getAsyncId());

      // set async id.
      InterceptorGroupInvocation transaction = interceptorGroup.getCurrentInvocation();
      if (transaction != null) {
        transaction.setAttachment(asyncTraceId);
        if (isDebug) {
          logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
        }
      }
    } catch (Throwable t) {
      logger.warn("Failed to before process. {}", t.getMessage(), t);
    }
  }
コード例 #2
0
 private AsyncTraceId injectAsyncTraceId(final Object asyncMethodCallObj, final Trace trace) {
   final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
   SpanEventRecorder recorder = trace.currentSpanEventRecorder();
   recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
   this.asyncTraceIdAccessor.set(asyncMethodCallObj, asyncTraceId);
   if (isDebug) {
     logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
   }
   return asyncTraceId;
 }