Distributed Tracing

Distributed handler chain tracing is used to monitor the network latencies and visualize the flow of requests through microservices. This guide shows how to use distributed tracing with ServiceComb in the BMI application.

Before you start

Walk through Develop microservice application in minutes and have BMI application running.

Enable

  1. Add distributed tracing dependency in pom.xml of BMI calculator service:

        <dependency>
          <groupId>org.apache.servicecomb</groupId>
          <artifactId>handler-tracing-zipkin</artifactId>
        </dependency>
    
  2. Add handler chain of distributed tracing in microservice.yaml of BMI calculator service:

    servicecomb:
      handler:
        chain:
          Provider:
            default: tracing-provider
    
  3. Add distributed tracing dependency in pom.xml of BMI web service:

        <dependency>
          <groupId>org.apache.servicecomb</groupId>
          <artifactId>spring-cloud-zuul-zipkin</artifactId>
        </dependency>
    

The above configurations have already set up in the code. All you need to do is as follows:

  1. Run Zipkin distributed service inside Docker.

    docker run -d -p 9411:9411 openzipkin/zipkin
    
  2. Restart BMI calculator service with the following command:

    mvn spring-boot:run -Drun.jvmArguments="-Dcse.handler.chain.Provider.default=tracing-provider"
    

    or

    #spring-boot-maven-plugin 2.x
     mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dcse.handler.chain.Provider.default=tracing-provider"
    
  3. Restart BMI web service with the following command:

    #spring-boot-maven-plugin 1.x
    mvn spring-boot:run -Drun.jvmArguments="-Dservicecomb.tracing.enabled=true"
    

    or

    #spring-boot-maven-plugin 2.x
     mvn spring-boot:run -Dspring-boot.run.jvmArguments="--Dservicecomb.tracing.enabled=true"
    

Verification

  1. Visit http://localhost:8889 . Input a positive height and weight and then click Submit button.

  2. Visit http://localhost:9411 to checkout the status of distributed tracing and get the following figure.

Distributed tracing result

What’s next