Giter Club home page Giter Club logo

brave-example's Introduction

Basic example showing distributed tracing across Java applications

This is an example app where two Java services collaborate on a request.

Notably, these services send data to Zipkin, a distributed tracing system. Zipkin allows you to see the how long the operation took, as well how much time was spent in each service.

Here's an example of what it looks like:

zipkin screen shot

Implementation Overview

This example has two services: frontend and backend. Both are instrumented to send tracing data to a third service Zipkin. Brave performs this function.

Running the example

To setup the demo, you need to start Frontend, Backend and Zipkin. You can do this using Java commands or Docker.

Once the services start, open http://localhost:8081/

Afterwards, you can view traces that went through the backend via http://127.0.0.1:9411/zipkin?serviceName=backend

  • This is a locally run zipkin service which keeps traces in memory

Tips

There are some interesting details that apply to all examples:

  • If you pass the header user_name Brave will automatically propagate it to the backend!
    • curl -s localhost:8081 -H'user_name: JC'
  • The below Logback pattern adds trace and span identifiers into log output
    • %d{HH:mm:ss.SSS} [%thread] [%X{userName}] [%X{traceId}/%X{spanId}] %-5level %logger{36} - %msg%n

Example projects

Here are the example projects you can try:

Starting the services with Docker

Docker Compose is the easiest way to start.

Just run docker-compose up.

Armeria starts by default. To use a different version of the project, set the VERSION variable.

Ex. VERSION=webmvc25-jetty docker-compose up

Starting the services from source

When not using Docker, you'll need to start services according to the frameworks used.

First, start Zipkin. This stores and queries traces reported by the example services.

Starting Zipkin with Java:

curl -sSL https://zipkin.io/quickstart.sh | bash -s
java -jar zipkin.jar

Java

In a separate tab or window, start each of brave.example.Frontend and brave.example.Backend.

Ex.

$ cd armeria
$ mvn compile exec:java -Dexec.mainClass=brave.example.Backend
$ mvn compile exec:java -Dexec.mainClass=brave.example.Frontend

Servlet

In a separate tab or window, start a Jetty container for "backend" and "frontend".

Ex.

$ cd webmvc4-jetty
$ mvn jetty:run -Pfrontend
$ mvn jetty:run -Pbackend

brave-example's People

Contributors

adriancole avatar colinzuo avatar denton-l avatar hyangtack avatar ikhoon avatar jeqo avatar kristofa avatar minwoox avatar objectiser avatar trustin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.