{"id":16118948,"url":"https://github.com/cch0/spring-boot-distributed-tracing-with-jaeger","last_synced_at":"2025-06-26T00:04:05.403Z","repository":{"id":84547374,"uuid":"193258527","full_name":"cch0/spring-boot-distributed-tracing-with-jaeger","owner":"cch0","description":"Distributed Tracing For Spring Boot Applications Using Jaeger","archived":false,"fork":false,"pushed_at":"2019-07-09T04:17:28.000Z","size":605,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-26T00:02:42.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cch0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-22T17:00:14.000Z","updated_at":"2024-04-15T05:04:49.000Z","dependencies_parsed_at":"2023-03-06T01:00:24.677Z","dependency_job_id":null,"html_url":"https://github.com/cch0/spring-boot-distributed-tracing-with-jaeger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cch0/spring-boot-distributed-tracing-with-jaeger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch0%2Fspring-boot-distributed-tracing-with-jaeger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch0%2Fspring-boot-distributed-tracing-with-jaeger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch0%2Fspring-boot-distributed-tracing-with-jaeger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch0%2Fspring-boot-distributed-tracing-with-jaeger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cch0","download_url":"https://codeload.github.com/cch0/spring-boot-distributed-tracing-with-jaeger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch0%2Fspring-boot-distributed-tracing-with-jaeger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261973724,"owners_count":23238586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T20:51:43.585Z","updated_at":"2025-06-26T00:04:05.203Z","avatar_url":"https://github.com/cch0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distributed Tracing For Spring Boot Applications Using Jaeger\n\n## Goal\n\nThe goal of this repository is to illustrate how to leverage Jaeger as the distributed tracing solution for Spring Boot applications.\n\nWith little configuration, trace information is passed between services and reported to Jaeger server and you can see the trace information in the Jaeger UI.\n\n## Contrived Example\n\nIn this repo, ideas and solutions are illustrated by applying them to a contrived example. There is not much real business related functionality implemented and the idea of the example is to have multiple services working together to loosely reflect a real world scenario.\n\nThere are 4 different services in this example. `Account Service` is the main service with which client (browser) interacts. `Account Service` in turns calls `Payment Service` and `Profile Service` for the relevant information for the requested account id. `Payment Service`, upon receiving the request, also calls `Credit Service` for the credit information. A random delay is added to each service's processing to simulate the time used in processing the business logic.\n\n\n![example](./docs/img/configuration.png)\n\n## Jaeger\n\n[Jaeger](https://github.com/jaegertracing/jaeger) is a distributed system provided by Uber. \n\n\u003eIt is used for monitoring and troubleshooting microservices-based distributed systems, including:\n\u003e* Distributed context propagation\n\u003e* Distributed transaction monitoring\n\u003e* Root cause analysis\n\u003e* Service dependency analysis\n\u003e* Performance / latency optimization\n\nIt is [OpenTracing]((https://opentracing.io/)) compatible and provides instrumentation libraries in major programming languages.\n\n\n## Spring Boot Configuration\n\nSpring Boot/Cloud integration is available via [java-spring-cloud](https://github.com/opentracing-contrib/java-spring-cloud) project. It is as simple as adding necessary dependency to the project.\n\n`pom.xml` configruation\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.opentracing.contrib\u003c/groupId\u003e\n    \u003cartifactId\u003eopentracing-spring-jaeger-cloud-starter\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\n`application.yaml` configuration\n```\nopentracing:\n  spring:\n    cloud:\n      log:\n        enabled: true\n  jaeger:\n    enabled: true\n    #    probabilistic-sampler:\n    #      sampling-rate: 1.0\n    log-spans: true\n    udp-sender:\n      host: localhost\n      port: 6831\n    # demonstration purpose only\n    const-sampler:\n      decision: true\n    service-name: account-service\n```\n\n\n## Building The Services\n\nInside the repository, each sub-directoy contains the source code for each service. Execute the maven command in each sub-directory to build each service\n\n```\nmvn clean verify\n```\n\nAlternatively, a `Dockerfile` is provided for each service. Execute the following command to build and containerize the service.\n\n```\ndocker-compose -f docker-compose.yaml build\n```\n\n## Running The Services\n\nFirst of all, stand up `Jaeger` server\n\n```\ndocker-compose -f docker-compose-infra.yaml up -d\n```\n\nThe, run the services\n\n```\ndocker-compose -f docker-compose.yaml up -d\n```\n\n## Generate Traces\n\n```\ncurl http://localhost:8080/accounts/123\n```\n\n`123` is the account id, any number will do.\n\n\n## Oberserve the Trace\n\nJaeger UI is available at `http://localhost:16686`\n\n\nFrom the left panel, select `account-service` from the `Services` dropdown list and click the `Find Traces` button.\n\nAll available traces will show up on the main panel. Click any trace to dive into details.\n\n![trace](docs/img/trace.png)\n\nClick a span will take you to the detail view about that particular span\n\n![span](docs/img/trace_detail.png)\n\nJaeger will also analyze the trace and provide the dependency graph.\n\n![dag](docs/img/service_dependency.png)\n\n\n## Continuous Integration: Google Cloud Build\n\nA Cloud Build `cloudbuild.yaml` file has been provided and the github repository has been configured to have a build triggered every time there is a commit pushed to any branch.\n\nInside `cloudbuild.yaml`, a Docker Cloud Builder is used to execute the `docker build` command for each service using the respective `Dockerfile`.\n\nIt is possible to extend this file to also push container image to a container registry such as GCR. \n\n## Continuous Integration: Gitlab CICD\n\nA `.gitlab-ci.yaml` file has been provided such that a build will be triggered every time a commit is pushed to any branch. What it currently does is to build each service using the provided `Dockerfile. It is possible to extend current pipeline to push container images to container register or deploy to target environment.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcch0%2Fspring-boot-distributed-tracing-with-jaeger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcch0%2Fspring-boot-distributed-tracing-with-jaeger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcch0%2Fspring-boot-distributed-tracing-with-jaeger/lists"}