0

我正在为微服务应用程序实现分布式跟踪。在 zipkin UI 中,我无法获取子 URL 路径。 在此处输入图像描述

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

在此处输入图像描述

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 的微服务的任何其他跟踪机制。

4

0 回答 0