pinpoint-apm / pinpoint

APM, (Application Performance Management) tool for large-scale distributed systems.
https://pinpoint-apm.gitbook.io/
Apache License 2.0
13.43k stars 3.76k forks source link

Loss of ptxid when using pointpoint to integrate gateway #7300

Open guoyuzhuang opened 4 years ago

guoyuzhuang commented 4 years ago

我这边使用pinpoint监控gateway,我的流程是client -> gateway -> order -> goods,现在的情况是,一次访问,每个应用都能打印到 PtxId ,但是gateway是一个 PtxId ,而 order跟goods是同样的 PtxId,也就是说,gateway生成的 PtxId 在请求order时丢失了,而 order生成的 PtxId 能够传递给 goods的

I use pinpoint to monitor the gateway. My process is client > gateway > order > goods. Now, every application can print to ptxid after a visit. However, gateway is a ptxid, and order and goods are the same ptxid. In other words, the ptxid generated by gateway is lost when the order is requested, and the ptxid generated by order can be passed to Good's

fushiqinghuan111 commented 3 years ago

I still found this problem in version 2.2.2 spring cloud gateway

Spring cloud gateway tixd missing

guoyuzhuang commented 3 years ago

Have you solved the problem? How did you solve it?

在 2021-03-10 19:59:23,"fushiqinghuan111" notifications@github.com 写道:

I still found this problem in version 2.2.2 spring cloud gateway

Spring cloud gateway tixd missing

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lijian69017436 commented 3 years ago

I also encountered this problem and there is no way to solve it temporarily

iwhalecloud-platform commented 2 years ago

org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter 链路中如果存在这个filter,并且走下面这段逻辑,就会导致http server handler的埋点提前退出,后续回调执行的逻辑找不到trace信息

               return ServerWebExchangeUtils.cacheRequestBody(exchange, (serverHttpRequest) -> {
            // don't mutate and build if same request object
            if (serverHttpRequest == exchange.getRequest()) {
                return chain.filter(exchange);
            }
            return chain.filter(exchange.mutate().request(serverHttpRequest).build());
        });
guoyuzhuang commented 2 years ago

org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter 链路中如果存在这个filter,并且走下面这段逻辑,就会导致http server handler的埋点提前退出,后续回调执行的逻辑找不到trace信息

               return ServerWebExchangeUtils.cacheRequestBody(exchange, (serverHttpRequest) -> {
          // don't mutate and build if same request object
          if (serverHttpRequest == exchange.getRequest()) {
              return chain.filter(exchange);
          }
          return chain.filter(exchange.mutate().request(serverHttpRequest).build());
      });

这个问题有没有办法解决呢?

iwhalecloud-platform commented 2 years ago

org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter 链路中如果存在这个filter,并且走下面这段逻辑,就会导致http server handler的埋点提前退出,后续回调执行的逻辑找不到trace信息

               return ServerWebExchangeUtils.cacheRequestBody(exchange, (serverHttpRequest) -> {
            // don't mutate and build if same request object
            if (serverHttpRequest == exchange.getRequest()) {
                return chain.filter(exchange);
            }
            return chain.filter(exchange.mutate().request(serverHttpRequest).build());
        });

这个问题有没有办法解决呢?

我是重写了pp的插件的,对spring cloud gateway load filter的逻辑做了个增强,添加一个filter。这个filter主要做一件事情: return chain.filter(exchange).doFinally(s ->{执行清理逻辑}),同时webflux里面其他埋点里不再从threadlocal里面取trace,初始化后放到,然后从ServerWebExchange中取。传统的threadlocal不适合reactor....