public ContextData beforeInvoke(Identification id) {
    try {
      Span spanData = ContextGenerator.generateSpanFromThreadLocal(id);
      // 设置SpanType的类型
      spanData.setTag(Tag.SPAN_TYPE, SpanType.RPC_CLIENT);

      if (Config.BuriedPoint.PRINTF) {
        logger.debug(
            "TraceId:"
                + spanData.getTraceId()
                + "\tParentLevelId:"
                + spanData.getParentLevel()
                + "\tLevelId:"
                + spanData.getLevelId()
                + "\tbusinessKey:"
                + spanData.getBusinessKey());
      }

      CurrentThreadSpanStack.push(spanData);

      sendRequestSpan(spanData, id);

      return new ContextData(
          spanData.getTraceId(), generateSubParentLevelId(spanData), spanData.getRouteKey());
    } catch (Throwable t) {
      logger.error(t.getMessage(), t);
      return new EmptyContextData();
    }
  }
  protected ContextData beforeInvoke(Span spanData, Identification id) {
    if (Config.BuriedPoint.PRINTF) {
      easyLogger.debug(
          "TraceId:"
              + spanData.getTraceId()
              + "\tParentLevelId:"
              + spanData.getParentLevel()
              + "\tLevelId:"
              + spanData.getLevelId()
              + "\tbusinessKey:"
              + spanData.getBusinessKey());
    }

    // 将新创建的Context存放到ThreadLocal栈中。
    CurrentThreadSpanStack.push(spanData);

    // 根据SpanData生成RequestSpan,并保存

    CurrentThreadSpanStack.push(spanData);

    sendRequestSpan(spanData, id);

    // 并将当前的Context返回回去
    return new ContextData(spanData);
  }
  protected void afterInvoke() {
    try {

      // 弹出上下文的栈顶中的元素
      Span spanData = CurrentThreadSpanStack.pop();

      if (Config.BuriedPoint.PRINTF) {
        easyLogger.debug(
            "TraceId-ACK:"
                + spanData.getTraceId()
                + "\tParentLevelId:"
                + spanData.getParentLevel()
                + "\tLevelId:"
                + spanData.getLevelId()
                + "\tbusinessKey:"
                + spanData.getBusinessKey());
      }

      sendAckSpan(spanData);
    } catch (Throwable t) {
      easyLogger.error(t.getMessage(), t);
    }
  }
  public DynamicType.Builder<?> define(String transformClassName, DynamicType.Builder<?> builder)
      throws PluginException {
    String interceptorDefineClassName = this.getClass().getName();

    if (StringUtil.isEmpty(transformClassName)) {
      logger.warn(
          "classname of being intercepted is not defined by {}.", interceptorDefineClassName);
      return builder;
    }

    logger.debug(
        "prepare to enhance class {} by {}.", transformClassName, interceptorDefineClassName);

    /** find witness classes for enhance class */
    String[] witnessClasses = witnessClasses();
    if (witnessClasses != null) {
      for (String witnessClass : witnessClasses) {
        Resolution witnessClassResolution = PluginBootstrap.CLASS_TYPE_POOL.describe(witnessClass);
        if (!witnessClassResolution.isResolved()) {
          logger.warn(
              "enhance class {} by plugin {} is not working. Because witness class {} is not existed.",
              transformClassName,
              interceptorDefineClassName,
              witnessClass);
          return builder;
        }
      }
    }

    /** find origin class source code for interceptor */
    DynamicType.Builder<?> newClassBuilder = this.enhance(transformClassName, builder);

    logger.debug(
        "enhance class {} by {} completely.", transformClassName, interceptorDefineClassName);

    return newClassBuilder;
  }
 public void send(String alarmKey, String traceId, String message) {
   Jedis jedis = null;
   try {
     jedis = AlarmRedisConnector.getJedis();
     if (jedis != null) return;
     jedis.hsetnx(alarmKey, traceId, message);
     jedis.expire(alarmKey, Config.Alarm.ALARM_EXPIRE_SECONDS);
   } catch (Exception e) {
     AlarmRedisConnector.reportJedisFailure();
     logger.error("Failed to set data.", e);
   } finally {
     if (jedis != null) {
       jedis.close();
     }
   }
 }
  protected void occurException(Throwable th) {
    try {
      if (exclusiveExceptionSet == null) {
        Set<String> exclusiveExceptions = new HashSet<String>();

        String[] exceptions = Config.BuriedPoint.EXCLUSIVE_EXCEPTIONS.split(EXCEPTION_SPLIT);
        for (String exception : exceptions) {
          exclusiveExceptions.add(exception);
        }
        exclusiveExceptionSet = exclusiveExceptions;
      }

      Span span = CurrentThreadSpanStack.peek();
      span.handleException(
          th, exclusiveExceptionSet, Config.BuriedPoint.MAX_EXCEPTION_STACK_LENGTH);
    } catch (Throwable t) {
      easyLogger.error(t.getMessage(), t);
    }
  }