Skip to content

wujack778/Tracing-service-bus-by-sleuth-and-Opentelemetry

Repository files navigation

Integrate spring cloud sleuth, opentelemetry and service bus

This repo used Spring Cloud Sleuth and Opentelemetry to track Service Bus SDK, Zipkin as a server for ui display. There is a gap between service bus and zipkin, the dependency between consumers and producers in the service bus cannot be fully displayed. This document is some conclusions about tracing the service bus through the above methods.

Introduction

This repo contains three parts, [ServiceBus JMS](#ServiceBus JMS), [ServiceBus Multibinders](#ServiceBus Multibinders) and ZipkinServer. Tracking the service bus, also refer to Spring cloud sleuth otel and Track Azure SDK for Java.

Getting started

Support

Running this repo will be charged by Azure. You can check the usage and bill at this link. Go to Azure portal and create the service by following this link.

Prerequisites

Clone source

If you want to clone from master, jump to Clone project from master branch.

Note that there is no need to add a version as those are managed already by the project.

Clone project from master branch

It means cloning the master branch, all the code, dependencies, and readme files are up to date.

  1. Clone code to local repo

    git clone https://github.com/wujack778/Tracing-service-bus-by-sleuth-and-Opentelemetry.git
    
  2. Traverse to the root directory

ServiceBus JMS

The module azure-servicebus-jms-queue-supplier and the module azure-servicebus-jms-queue-consumer are refer to Service Bus Jms For the configuration of their application.yaml, please refer to Service Bus Jms Readme.

How to run

  1. Run with Maven
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/azure-servicebus-jms-queue-consumer
    mvn spring-boot:run
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/azure-servicebus-jms-queue-supplier
    mvn spring-boot:run
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/zipkin-server
    mvn spring-boot:run   
    
  2. Send a POST request to service bus queue.
    $ curl -X POST localhost:8899/queue?message=hello
    
  3. Verify in your app's logs that a similar message was posted:
    Sending message
    Received message from queue: hello
    
  4. Zipkin server will show the results of tracing ZipkinServer.

ServiceBus Multibinders

Module azure-servicebus-queue-multibinders-consumer01, Module azure-servicebus-queue-multibinders-consumer02 and Module azure-servicebus-queue-multibinders-supplier are refer to Service Bus Multi binders For the configuration of their application.yaml, please refer to Service Bus Multi binders Config

How to run

  1. Run with Maven
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/azure-servicebus-queue-multibinders-consumer01
    mvn spring-boot:run
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/azure-servicebus-queue-multibinders-consumer02
    mvn spring-boot:run
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/azure-servicebus-queue-multibinders-supplier
    mvn spring-boot:run
    cd Tracing-service-bus-by-sleuth-and-Opentelemetry/zipkin-server
    mvn spring-boot:run   
    
  2. Send a POST request to test the default binder.
    $ curl -X POST localhost:9000/messages1?message=hello
    
  3. Verify in your app's logs that a similar message was posted:
     New message1 received: 'hello'
     Message1 'hello' successfully checkpointed
    
  4. Send another POST request to test the other binder
    $ curl -X POST localhost:9000/messages2?message=hello
    
  5. Verify in your app's logs that a similar message was posted:
     New message2 received: 'hello'
     Message2 'hello' successfully checkpointed
    
  6. Zipkin server will show the results of tracing ZipkinServer.

ZipkinServer

How to run

  1. Request to zipkin server Go back to your browser and request the following link http://localhost:8080/, you will see the following situation: Zipkin Server

  2. View the tracing result

  • Click this span Zipkin Server Span

  • Every span, time consuming per span and request will be displayed. Span Request Time JMS

  • Click every span, traceId, spanId, parentId will be displayed. Trace Id Image JMS

  • Click the Dependencies, the topological diagram of the dependencies will be displayed.

    JMS Result Dependencies Image JMS Multi Binders Result Dependencies Image Multi Binders

Configurable properties

Common properties

Properties Description
spring.application.name Customize your application name
server.port Customize your application server port
spring.sleuth.sampler.probability Probability of requests that should be sampled, eg 0.5 or 1
spring.zipkin.base-url Base url of your zipkin server

About

Tracing service bus by sleuth and Opentelemetry

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages