使用 zipkin 时未为子调用捕获 URL 路径

问题描述

我正在为微服务应用程序实现分布式跟踪。在 zipkin UI 中,我无法获得子 URL 路径。

enter image description here

对于父调用,整个 URL 被捕获,如“post/cart/create”。但是对于孩子来说,只有“get”和“post”。未显示子呼叫的完整 URL。如何解决这个问题?需要帮助。

enter image description here

Zipkin_spans 表中的数据如上所示。

我的呼叫服务代码

public Cart createCartItem(Cart cartItem,String userId) {
        Map<String,String> params = new HashMap<String,String>();
        params.put("userId",userId);
        String inventoryUrl
          = "http://item-service/inventory/get/"+cartItem.getItem_id();
        ResponseEntity<Integer> response
          = restTemplate.getForEntity(inventoryUrl,Integer.class,params);
        if(!response.equals(0)) {
            Cart cart = cartRepository.save(cartItem);
            String inventoryQtyUpdateUrl
              = "http://item-service/inventory/qty/"+cartItem.getItem_id();
            restTemplate.postForLocation(inventoryQtyUpdateUrl,null,params);
            return cart;
        }
        return null;
    }

我使用的依赖是

  1. spring-cloud-starter-sleuth
  2. spring-cloud-sleuth-zipkin

这个问题好像不一致。有时它显示整个 URL,有时不显示。经过多次测试,我才知道这一点。我什至用 spring-cloud-starter-zipkin 进行了测试。但它也没有显示出任何有希望的结果。

因此,如果需要整个 URL,那么我根本不应该使用 zipkin 吗?建议使用 spring 的任何其他微服务跟踪机制。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)