Spring Sleuth 卡住了向 Zipkin 发送 10% 的请求

     2023-02-26     83

关键词:

【中文标题】Spring Sleuth 卡住了向 Zipkin 发送 10% 的请求【英文标题】:Spring Sleuth stuck sending 10 percent of request to Zipkin 【发布时间】:2018-08-17 08:50:00 【问题描述】:

默认情况下,Spring Sleuth 只向 Zipkin 发送 10% 的请求。通过设置spring.sleuth.sampler.percentage,您可以增加百分比。不幸的是,无论我将其设置为什么值,它都停留在 10%。我试过 1.0、0.5、1、100。

来自/env的输出

            "spring.sleuth.sampler.percentage": 
                "value": 1,
                "origin": "class path resource [application.yml]:77:19"
            

无论价值多少,当我发出多个请求时,只有 10% 的请求到达 Zipkin。

我们使用的是 Spring Cloud 的 Finchley.M8 版本和 Spring Boot 的 2.0.0.RELEASE。

以下是相关的 POM 设置。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-cloud.version>Finchley.M8</spring-cloud.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>$spring-cloud.version</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

    <dependency> 
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-zipkin</artifactId>
    </dependency>

这可能是一个错误吗?

【问题讨论】:

【参考方案1】:

好的,我们发现了问题,也找到了解决方法。

看起来所有的文档都是错误的,至少对于我们使用的 Spring Cloud Sleuth 版本。正确的属性不是spring.sleuth.sampler.percentage。正确的属性是spring.sleuth.sampler.probability

这是我们在注意到属性错误之前发现的一种解决方法。

@Bean
public Sampler alwaysSampler() 
    return Sampler.ALWAYS_SAMPLE;

这里有一些来自 Spring Cloud 的官方文档,其中包含错误的属性。

https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.0.0.M5/single/spring-cloud-sleuth.html

https://cloud.spring.io/spring-cloud-sleuth/single/spring-cloud-sleuth.html

这是正在使用的源代码,它使用的是probability 而不是percentage

https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/sampler/SamplerProperties.java

【讨论】:

当 spring-cloud-starter-zipkin 使用 zipkin.brave 时,为啥需要 Spring sleuth?

】当spring-cloud-starter-zipkin使用zipkin.brave时,为啥需要Springsleuth?【英文标题】:whyneedSpringsleuthwhenspring-cloud-starter-zipkinuseszipkin.brave?当spring-cloud-starter-zipkin使用zipkin.brave时,为什么需要Springsleuth?【发布时间】:2021-10-2520:52 查看详情

Spring cloud sleuth 没有与 Zipkin 一起运行

】Springcloudsleuth没有与Zipkin一起运行【英文标题】:SpringcloudsleuthdidnotrunwithZipkin【发布时间】:2019-02-0109:50:49【问题描述】:首先我对这门课有一个小问题brave.sampler.Sampler无法导入此类,仅在我添加此依赖项时导入<dependency>&... 查看详情

spring-cloud-sleuth-zipkin实现微服务的链路跟踪

spring-cloud-sleuth-zipkin实现微服务的链路跟踪简介在微服务数量较多的系统架构中,一个完整的HTTP请求可能需要经过好几个微服务。如果想要跟踪一条完整的HTTP请求链路所产生的日志,我们需要到各个微服务上去查看日志并检索... 查看详情

sleuth+zipkin服务链路追踪(代码片段)

官方文档:https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.1.3.RELEASE/single/spring-cloud-sleuth.html一、为什么要用链路追踪微服务架构是一个分布式架构,它按业务划分服务单元,一个分布式系统往往有很多个服务单元... 查看详情

sleuth+zipkin服务链路追踪(代码片段)

官方文档:https://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.1.3.RELEASE/single/spring-cloud-sleuth.html一、为什么要用链路追踪微服务架构是一个分布式架构,它按业务划分服务单元,一个分布式系统往往有很多个服务单元... 查看详情

全链路追踪spring-cloud-sleuth-zipkin

...候,请求链路的追踪是十分有必要的,鉴于项目中采用的springcloud架构,所以为了方便使用,便于接入等项目中采用了springcloudsleuth+zipkin。现总结如下:   springcloudsleuth+zipkin 总共分为几个角色:    1... 查看详情

如何解决 Spring-cloud-sleuth-zipkin (Edgware.SR5) 中的 RabbitMQ 服务器连接错误

】如何解决Spring-cloud-sleuth-zipkin(Edgware.SR5)中的RabbitMQ服务器连接错误【英文标题】:HowtoresolveRabbitMQServerconnectionerrorinSpring-cloud-sleuth-zipkin(Edgware.SR5)【发布时间】:2019-04-1200:17:38【问题描述】:我需要通过RabbitMQ将span发送到Zipkin。... 查看详情

springcloudsleuth+zipkin实现服务追踪

服务追踪SpringCloudSleuth实现了一种分布式的服务链路跟踪解决方案,通过使用Sleuth可以让我们快速定位某个服务的问题。官方文档地址如下:http://cloud.spring.io/spring-cloud-static/spring-cloud-sleuth/2.0.1.RELEASE/single/spring-cloud-sleuth.html一些... 查看详情

sleuth-zipkin-链路监控(代码片段)

1.【微服务】依赖:<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-sleuth</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-zipkin... 查看详情

从零搭建一个springcloud项目之sleuth+zipkin(代码片段)

在需要加监控的服务上进行以下操作一、加入Sleuth加依赖<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-sleuth</artifactId></dependency>二、加入Zipkin2.1使 查看详情

sleuth+zipkin链路追踪示例(代码片段)

...ack.cn/read/dyingbleed-zipkin/326d459d6b9268be.md文档2:ttps://www.springcloud.cc/spring-cloud-greenwich.html#_spring_cloud_sleuthZipkinisadistributedtracingsystem.Ithelpsgathertimingdataneededtotroubleshootlatencyproblemsinservicearchitectures.Featuresincludeboththecollectionandlookupofthis... 查看详情

Spring cloud sleuth 注解:自动装配不起作用

】Springcloudsleuth注解:自动装配不起作用【英文标题】:SpringcloudsleuthAnnotations:Autowiringdoesn\'twork【发布时间】:2020-07-1310:21:14【问题描述】:我在我的应用程序中配置了Springcloudsleuth(还有zipkin)。我有一个调用服务的控制器,... 查看详情

springcloudalibaba(15)---sleuth+zipkin(代码片段)

SpringCloudAlibaba整合Sleuth+Zipkin有关Sleuth之前有写过两篇文章SpringCloudAlibaba(13)---Sleuth概述SpringCloudAlibaba(14)---SpringCloudAlibaba整合Sleuth上篇文章我们通过打印日志的方式,看到一个请求的完整链路。但是当微服务越来越多日志文件也会... 查看详情

springcloud学习之sleuth+zipkin

一、什么是Sleuth  为服务之间调用提供链路追踪。通过Sleuth可以很清楚的了解到一个服务请求经过了哪些服务,每个服务处理花费了多长。从而让我们可以很方便的理清各微服务间的调用关系。二、Sleuth作用  2.1:耗时分析... 查看详情

添加 sleuth 和 zipkin 时应用程序无法启动

】添加sleuth和zipkin时应用程序无法启动【英文标题】:appfailstostartwhensleuthandzipkinareadded【发布时间】:2017-07-1304:08:58【问题描述】:我有一个要更新到1.5.1的SpringBoot应用程序。效果很好,直到我将Sleuth和Zipkin添加到类路径<depen... 查看详情

sleuth+zipkin实现springcloud链路追踪(代码片段)

文章目录一、前言二、应用架构图三、快速了解Sleuth四、准备工作1、搭建Zipkin单机环境2、搭建naocos单机环境五、微服务整合Sleuth1、创建SpringBoot工程2、配置文件3、实现核心代码六、集成Zipkin1、引入客户端2、配置文件3、运行效... 查看详情

链路追踪zipkin+sleuth解决illegalcharacterinschemenameatindex0:192.168.100.130:9411/xxx/xx(代码片段)

...erties或application.yml配置文件错误的写法应该改为注意前缀spring.zipkin.base-url=http://192.168.100.130:9411/此时访问就恢复正常了 查看详情

springcloud链路追踪sleuth+twitterzipkin中zipkin服务

2021年5月15日随笔springboot2.2.x版本以上,不建议自己写服务了,我尝试了很多方法没有成功,各种问题,所以需要下载它的jar包然后执行 下载地址:https://repo1.maven.org/maven2/io/zipkin/zipkin-server/2.23.2/zipkin-server-2.23.2-exec.jar下载完... 查看详情