{"id":13694560,"url":"https://github.com/openzipkin/brave-example","last_synced_at":"2025-10-27T15:15:18.238Z","repository":{"id":8021424,"uuid":"9430405","full_name":"openzipkin/brave-example","owner":"openzipkin","description":"A collection of examples how to use brave instrumentation in various frameworks and libraries.","archived":false,"fork":false,"pushed_at":"2024-03-09T23:11:37.000Z","size":596,"stargazers_count":209,"open_issues_count":3,"forks_count":139,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-04-09T21:11:54.162Z","etag":null,"topics":["brave","distributed-tracing","openzipkin","zipkin"],"latest_commit_sha":null,"homepage":"https://gitter.im/openzipkin/zipkin","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openzipkin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2013-04-14T14:51:32.000Z","updated_at":"2024-04-14T19:34:08.123Z","dependencies_parsed_at":"2024-03-03T05:32:29.808Z","dependency_job_id":"9b488b0c-b186-418b-bdc0-876dda180ef8","html_url":"https://github.com/openzipkin/brave-example","commit_stats":{"total_commits":173,"total_committers":14,"mean_commits":"12.357142857142858","dds":0.6936416184971098,"last_synced_commit":"59215c36ce8ec12cbb2358fd6e7e6b494bc42b29"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzipkin%2Fbrave-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzipkin%2Fbrave-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzipkin%2Fbrave-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzipkin%2Fbrave-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openzipkin","download_url":"https://codeload.github.com/openzipkin/brave-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399878,"owners_count":20932880,"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":["brave","distributed-tracing","openzipkin","zipkin"],"created_at":"2024-08-02T17:01:34.786Z","updated_at":"2025-10-27T15:15:13.203Z","avatar_url":"https://github.com/openzipkin.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# Basic example showing distributed tracing across Java applications\nThis is an example app where two Java services collaborate on a request.\n\nNotably, these services send data to [Zipkin](https://zipkin.io/), a\ndistributed tracing system. Zipkin allows you to see how long the operation\ntook, as well how much time was spent in each service.\n\nHere's an example of what it looks like:\n\n\u003cimg width=\"979\" alt=\"zipkin screen shot\" src=\"https://user-images.githubusercontent.com/64215/95572045-f98cfb80-0a5b-11eb-9d3b-9a1b9b1db6b4.png\"\u003e\n\n# Implementation Overview\nThis example has two services: frontend and backend. Both are [instrumented](https://github.com/openzipkin/brave/tree/master/instrumentation)\nto send tracing data to a third service [Zipkin](https://zipkin.io/). [Brave](https://github.com/openzipkin/brave)\nperforms this function.\n\n# Running the example\nTo set up the demo, you need to start Frontend, Backend and Zipkin. You can do\nthis using Java commands or Docker.\n\nOnce the services start, open http://localhost:8081/\n* This calls the backend (http://127.0.0.1:9000/api) and shows its result: a formatted date.\n\nAfterward, you can view traces that went through the backend via http://127.0.0.1:9411/zipkin?serviceName=backend\n* This is a locally run zipkin service which keeps traces in memory\n\n## Tips\n\nThere are some interesting details that apply to all examples:\n* If you pass the header `user_name` Brave will automatically propagate it to the backend!\n  * `curl -s localhost:8081 -H'user_name: JC'`\n* The below Logback pattern adds trace and span identifiers into log output\n  * `%d{HH:mm:ss.SSS} [%thread] [%X{userName}] [%X{traceId}/%X{spanId}] %-5level %logger{36} - %msg%n`\n\n## Example projects\n\nHere are the example projects you can try:\n\n* [armeria](armeria) `BRAVE_EXAMPLE=armeria docker compose up`\n  * Runtime: Armeria, SLF4J 1.7, JRE 21\n  * Trace Instrumentation: [Armeria](https://armeria.dev/), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](armeria/src/main/java/brave/example/HttpTracingFactory.java)\n  * You can also use Eureka discovery like this:\n    * `BRAVE_EXAMPLE=armeria docker compose -f docker-compose.yml -f docker-compose-eureka.yml up`\n\n* [armeria-kafka](armeria-kafka) `BRAVE_EXAMPLE=armeria-kafka docker compose -f docker-compose.yml -f docker-compose-kafka.yml up`\n  * Runtime: Armeria, Kafka Clients and Streams 2.7, SLF4J 1.7, JRE 21\n  * Trace Instrumentation: [Armeria](https://armeria.dev/), [Kafka Clients](https://github.com/openzipkin/brave/tree/master/instrumentation/kafka-clients), [Kafka Streams](https://github.com/openzipkin/brave/tree/master/instrumentation/kafka-streams), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](armeria/src/main/java/brave/example/HttpTracingFactory.java)\n\n* [jersey2-cassandra3](jersey2-cassandra3) `BRAVE_EXAMPLE=jersey2-cassandra3 docker compose up`\n  * Runtime: JaxRS 2, Jersey 2, DataStax Java Driver 3, Apache Cassandra 4, SLF4J 1, JRE 8\n  * Trace Instrumentation: [Jersey Server](https://github.com/openzipkin/brave/tree/master/instrumentation/jersey-server), [DataStax Java Driver](https://github.com/openzipkin/brave-cassandra/tree/master/cassandra-driver), [Apache Cassandra](https://github.com/openzipkin/brave-cassandra/tree/master/cassandra), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [XML](jersey2-cassandra3/src/main/webapp/WEB-INF/tracing.xml)\n\n* [netty4-grpc](netty4-grpc) `BRAVE_EXAMPLE=netty4-grpc docker compose up`\n  * Runtime: Netty 4.1, Google gRPC 1.63, SLF4J 1.7, JRE 21\n  * Trace Instrumentation: [Netty Codec HTTP](https://github.com/openzipkin/brave/tree/master/instrumentation/netty-codec-http), [Google gRPC](https://github.com/openzipkin/brave/tree/master/instrumentation/grpc), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Java](netty4-grpc/src/main/java/brave/example/TracingConfiguration.java)\n\n* [webflux5-sleuth](webflux5-sleuth) `BRAVE_EXAMPLE=webflux5-sleuth docker compose up`\n  * Runtime: Spring 5, Reactor Netty 0.9, Spring Boot 2.3, Spring Cloud Sleuth 2.2, Log4J 2.13, JRE 21\n  * Trace Instrumentation: [WebFlux Server](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebFilter.java), [WebFlux Client](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/client/TraceWebClientBeanPostProcessor.java), [Reactor Context](https://github.com/spring-cloud/spring-cloud-sleuth/blob/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/reactor/ScopePassingSpanSubscriber.java), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Spring Cloud Sleuth](https://github.com/spring-cloud/spring-cloud-sleuth/tree/2.2.x/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig) [Properties](webflux5-sleuth/src/main/resources/application.properties)\n  * You can also use Eureka discovery like this:\n    * `BRAVE_EXAMPLE=webflux5-sleuth docker compose -f docker-compose.yml -f docker-compose-eureka.yml up`\n\n* [webflux6-micrometer](webflux6-micrometer) `BRAVE_EXAMPLE=webflux6-micrometer docker compose up`\n  * Runtime: Spring 6, Reactor Netty, Spring Boot 3, Micrometer, Log4J 2, JRE 21\n  * Trace Configuration: [Spring Boot Actuator](https://github.com/spring-projects/spring-boot/blob/3.2.x/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java)\n\n* [webmvc25-jetty](webmvc25-jetty) `BRAVE_EXAMPLE=webmvc25-jetty docker compose up`\n  * Runtime: Spring 2.5, Apache HttpClient 4.3, Servlet 2.5, Jetty 7.6, Log4J 1.2, JRE 6\n  * Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Apache HttpClient](https://github.com/openzipkin/brave/tree/master/instrumentation/httpclient), [Log4J 1.2](https://github.com/openzipkin/brave/tree/master/context/log4j12)\n  * Trace Configuration: [Brave Spring Beans](https://github.com/openzipkin/brave/tree/master/spring-beans#configuration) [XML](webmvc25-jetty/src/main/webapp/WEB-INF/applicationContext.xml)\n\n* [webmvc3-jetty](webmvc3-jetty) `BRAVE_EXAMPLE=webmvc3-jetty docker compose up`\n  * Runtime: Spring 3.2, Apache HttpClient 4.3, Servlet 3.0, Jetty 8.1, Log4J 1.2, JRE 7\n  * Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Spring Web](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-web), [Apache HttpClient](https://github.com/openzipkin/brave/tree/master/instrumentation/httpclient), [Log4J 1.2](https://github.com/openzipkin/brave/tree/master/context/log4j12)\n  * Trace Configuration: [Brave Spring Beans](https://github.com/openzipkin/brave/tree/master/spring-beans#configuration) [XML](webmvc3-jetty/src/main/webapp/WEB-INF/applicationContext.xml)\n\n* [webmvc4-jetty](webmvc4-jetty) `BRAVE_EXAMPLE=webmvc4-jetty docker compose up`\n  * Runtime: Spring 4.3, OkHttp 3.12, Jetty 9.2, Servlet 3.1, SLF4J 1.7, JRE 8\n  * Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Spring Web](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-web), [OkHttp](https://github.com/openzipkin/brave/tree/master/instrumentation/okhttp3), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Spring Java Config](webmvc4-jetty/src/main/java/brave/example/TracingConfiguration.java)\n\n* [webmvc4-boot](webmvc4-boot) `BRAVE_EXAMPLE=webmvc4-boot docker compose up`\n  * Runtime: Spring 4.3, OkHttp 3.14, Spring Boot 1.5, Servlet 3.1, Jetty 9.4, SLF4J 1.7, JRE 8\n  * Trace Instrumentation: [Servlet](https://github.com/openzipkin/brave/tree/master/instrumentation/servlet), [Spring MVC](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-webmvc), [Spring Web](https://github.com/openzipkin/brave/tree/master/instrumentation/spring-web), [OkHttp](https://github.com/openzipkin/brave/tree/master/instrumentation/okhttp3), [SLF4J](https://github.com/openzipkin/brave/tree/master/context/slf4j)\n  * Trace Configuration: [Brave API](https://github.com/openzipkin/brave/tree/master/brave#setup) [Spring Boot AutoConfiguration](webmvc4-boot/src/main/java/brave/example/TracingAutoConfiguration.java)\n\n## Starting the services with Docker\n\n[Docker Compose](https://docs.docker.com/compose/) is the easiest way to start.\n\nJust run `docker compose up`.\n\nArmeria starts by default. To use a different version of the project, set the `VERSION` variable.\n\nEx. `VERSION=webmvc25-jetty docker compose up`\n\n## Starting the services from source\n\nWhen not using Docker, you'll need to start services according to the frameworks used.\n\nFirst, start [Zipkin](https://zipkin.io/). This stores and queries traces\nreported by the example services. \n\nStarting Zipkin with Java:\n```bash\ncurl -sSL https://zipkin.io/quickstart.sh | bash -s\njava -jar zipkin.jar\n```\n\n### Java\nIn a separate tab or window, start each of `brave.example.Frontend` and `brave.example.Backend`.\n\nEx.\n```bash\n$ cd armeria\n$ mvn compile exec:java -Dexec.mainClass=brave.example.Backend\n$ mvn compile exec:java -Dexec.mainClass=brave.example.Frontend\n```\n\n### Servlet\nIn a separate tab or window, start a Jetty container for \"backend\" and \"frontend\".\n\nEx.\n```bash\n$ cd webmvc4-jetty\n$ mvn jetty:run -Pfrontend\n$ mvn jetty:run -Pbackend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenzipkin%2Fbrave-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenzipkin%2Fbrave-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenzipkin%2Fbrave-example/lists"}