Jose Martinez
Jose Martinez

Reputation: 12022

Spring Sleuth stuck sending 10 percent of request to Zipkin

By default Spring Sleuth only sends 10% of requests to Zipkin. By setting spring.sleuth.sampler.percentage you can increase the percentage. Unfortunately it is stuck at 10% regardless of what value I set it to. I have tried 1.0, 0.5, 1, 100.

Output from /env

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

Regardless of the value, when I make multiple requests, only 10% make it to Zipkin.

We are using version Finchley.M8 of Spring Cloud and 2.0.0.RELEASE of Spring Boot.

Below are relevant POM settings.

<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>

Could this be a bug?

Upvotes: 2

Views: 4676

Answers (1)

Jose Martinez
Jose Martinez

Reputation: 12022

Ok we found the problem and also a work around.

It looks like all the documentation out there is wrong, at least for the version of Spring Cloud Sleuth we are using. The correct property is not spring.sleuth.sampler.percentage. The correct property is spring.sleuth.sampler.probability

And here is a workaround we found right before noticing that the property was wrong.

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

Here are some official documentation from Spring Cloud that contain the wrong property.

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

Here is the source code that is being used and it is using probability not 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

Upvotes: 9

Related Questions