Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable distributed tracing for development

We are setting up microservice framework.

We use following stack for distributed tracing.

  • Spring boot
  • Kafka
  • Zipkin

Following is how the configuration is done

In gradle.build (or pom.xml) following starter dependencies added

compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-sleuth-zipkin'
compile 'org.springframework.cloud:spring-cloud-starter-bus-kafka'

Add one AlwaysSampler bean

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

If we have kafka running, things work automatically.

But if kafka is not running, server does not start - this is mostly the case for development environment.

If I want to stop this, I have to comment out all the code mentioned here (as we use starter dependency with spring boot, it automatically configures as I understand).

Can we just make some changes in properties (or yaml) files so that I don't need to go and comment out all these code?

Or probably another way to disable this without doing some commenting, etc.

like image 718
Akshay Avatar asked Jun 10 '19 11:06

Akshay


People also ask

What is distributed tracing in spring boot?

Distributed tracing is a technique to monitor and profile the applications, especially those built using microservice architecture. It is also known as distributed request tracing. Developers use distributed tracing to debug and optimize the code.

Is zipkin deprecated?

spring-cloud-starter-zipkin is deprecated, you should not use it anymore. You can use spring-cloud-starter-sleuth and spring-cloud-sleuth-zipkin ( 3. x ).

Why do we need zipkin?

Zipkin helps you find out exactly where a request to the application has spent more time. Whether it's an internal call inside the code or an internal or external API call to another service, you can instrument the system to share a context. Microservices usually share context by correlating requests with a unique ID.

How do you turn on zipkin in spring boot?

For YAML users, add the below property in application. yml file. Add the @EnableZipkinServer annotation in your main Spring Boot application class fie. The @EnableZipkinServer annotation is used to enable your application act as a Zipkin server.


1 Answers

You can add the following setting on your properties key to disable zipkin, source.

spring.zipkin.enabled=false

Better yet, create separate development properties (like application-dev.properties) to avoid changing above setting everytime you want to run in your machine: https://stackoverflow.com/a/34846351/4504053

like image 124
Adhika Setya Pramudita Avatar answered Oct 08 '22 20:10

Adhika Setya Pramudita