Spring-cloud-sleuth: Disabling Zipkin breaks start up

Created on 23 Jan 2019  路  9Comments  路  Source: spring-cloud/spring-cloud-sleuth

Hi, thanks for a great project!

I just added Sleuth + Zipkin to a project I'm working on. When I'm disabling Zipkin with spring.zipkin.enabled=false, the app fails at runtime with:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method spanBytesEncoder in org.springframework.cloud.sleuth.zipkin2.ZipkinBackwardsCompatibilityAutoConfiguration required a bean of type 'org.springframework.cloud.sleuth.zipkin2.ZipkinProperties' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.cloud.sleuth.zipkin2.ZipkinProperties' in your configuration.

Seems like a bug to me - just using Sleuth should still work. I've made a reproduction gist.


Dependencies

| Dependency | Version |
|---------------------------------------------------------|--------------------------------------------------|
| org.springframework.boot:spring-boot-starter-parent | 2.1.2.RELEASE |
| org.springframework.cloud:spring-cloud-sleuth | 2.1.0.RELEASE |
| org.springframework.cloud:spring-cloud-starter-zipkin | 2.1.0.RELEASE (managed by spring-cloud-sleuth) |

bug

Most helpful comment

Or you could add @EnableConfigurationProperties(ZipkinProperties.class) to your own config, which will get you out of this startup problem too. :)
In the meantime a fix has been created.

All 9 comments

I got the same failure after updating spring-cloud-starter-zipkin from 2.0.2.RELEASE to 2.1.0.RELEASE.

Yes, that apparently is a bug. Quick workaround is to disable sleuth altogether with spring.sleuth.enabled=false.

@TYsewyn I know, but that kind of defeats the purpose (at least for my use case). I want to _disable_ Zipkin and keep Sleuth _enabled_. This way I should get tracing in my logs, but not have any outgoing traffic (e.g. sending traces to Zipkin).

Hopefully that workaround can be useful for someone else :-)

Another fix: can you try adding spring-cloud-sleuth without zipkin to your project.
AFAIK you will have the same functionality without sending the traces.

Yup. My use case is maybe somewhat special. I want to disable Zipkin by default, but enable it in a custom zipkin profile :)

Looks like this was introduced by #1181

An alternate workaround would be to create this bean in your non-zipkin profile:

    @Bean
    Reporter<Span> reporter() {
        return Reporter.NOOP;
    }

EDIT: only 1 bean needed

Or you could add @EnableConfigurationProperties(ZipkinProperties.class) to your own config, which will get you out of this startup problem too. :)
In the meantime a fix has been created.

@EnableConfigurationProperties(ZipkinProperties.class) - this is the best workaround

Upgraded spring-cloud-starter-zipkin to 2.1.1.RELEASE to fix this issue, not sure though if 2.1.0 had a fix for this or not.

Was this page helpful?
0 / 5 - 0 ratings