• Stars
    star
    210
  • Rank 183,217 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated 22 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of examples how to use brave instrumentation in various frameworks and libraries.

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

More Repositories

1

zipkin

Zipkin is a distributed tracing system
Java
16,769
star
2

brave

Java distributed tracing implementation compatible with Zipkin backend services.
Java
2,327
star
3

zipkin-go

Zipkin distributed tracing library for go.
Go
604
star
4

zipkin-js

Zipkin instrumentation for Node.js and browsers
JavaScript
561
star
5

b3-propagation

Repository that describes and sometimes implements B3 propagation
518
star
6

zipkin4net

A .NET client library for Zipkin
C#
341
star
7

zipkin-php

Zipkin instrumentation for PHP
PHP
270
star
8

zipkin-dependencies

Spark job that aggregates zipkin spans for use in the UI
Java
174
star
9

zipkin-reporter-java

Shared library for reporting zipkin spans on transports such as http or kafka
Java
122
star
10

zipkin-ruby

zipkin-tracer ruby gem
Ruby
98
star
11

zipkin-gcp

Reporters and collectors for use in Google Cloud Platform
Java
89
star
12

zipkin-aws

Reporters and collectors for use in Amazon's cloud
Java
69
star
13

zipkin-php-example

See how much time php services spend on an http request
PHP
59
star
14

zipkin-api

Zipkin's language independent model and HTTP Api Definitions
Thrift
59
star
15

zipkin-js-example

Example project that shows how to use zipkin with javascript
JavaScript
58
star
16

zipkin-finagle

Integration between Finagle tracing to Zipkin transports such as http and kafka
Java
40
star
17

openzipkin.github.io

content for https://zipkin.io
HTML
39
star
18

zipkin-browser-extension

Chrome and Firefox browser extensions for Zipkin
JavaScript
25
star
19

pyramid_zipkin-example

See how much time python services spend on an http request
Python
14
star
20

brave-cassandra

Tracing instrumentation for Cassandra and the DataStax Java Driver
Java
12
star
21

docker-java

A small Docker image based on azul/zulu-openjdk-alpine
Shell
11
star
22

zipkin-api-example

Example of how to use the OpenApi/Swagger api spec
Go
9
star
23

brave-karaf

Karaf integration and tests for Brave (java Zipkin tracer)
Java
6
star
24

zipkin-layout-factory

Spring Boot Layout Factory for Zipkin Server derivatives
Shell
6
star
25

zipkin-support

repository for support questions raised as issues
4
star
26

zipkin-ruby-example

Ruby
4
star
27

docker-alpine

Alpine Linux base layer for Zipkin Docker images
Shell
3
star
28

zipkin-release

Documentation and templates used for projects released the same way as OpenZipkin
Python
1
star