|
| 1 | +# OpenCensus Spring Starter |
| 2 | +[![Build Status][travis-image]][travis-url] |
| 3 | +[![Windows Build Status][appveyor-image]][appveyor-url] |
| 4 | +[![Maven Central][maven-image]][maven-url] |
| 5 | + |
| 6 | +The *OpenCensus Spring Starter for Java* is a starter package that includes |
| 7 | +packages required to enable tracing using opencensus when working with [Spring Web][spring-web-url]. |
| 8 | + |
| 9 | +This version is compatible with [Spring Boot 2.0][spring-boot-2.0-url]. |
| 10 | + |
| 11 | +## Servlet and AsyncRestTemplate Tracing |
| 12 | + |
| 13 | +Enable tracing on RestController (server side) and AysncRestTemplate (client side) by simply including opencensus-contrib-spring-starter in your dependencies and |
| 14 | +initializing exporter. It automatically traces your http request and collects stats associated with the |
| 15 | +request. |
| 16 | + |
| 17 | +It does require to register exporter and views. |
| 18 | + |
| 19 | +### Depedencies |
| 20 | + |
| 21 | +#### Maven |
| 22 | + |
| 23 | +```xml |
| 24 | +<dependencies> |
| 25 | + <dependency> |
| 26 | + <groupId>io.opencensus</groupId> |
| 27 | + <artifactId>opencensus-contrib-spring-starter</artifactId> |
| 28 | + <version>0.23.0</version> |
| 29 | + </dependency> |
| 30 | +</dependencies> |
| 31 | + |
| 32 | +``` |
| 33 | + |
| 34 | +#### Gradle |
| 35 | +```gradle |
| 36 | +dependencyManagement { |
| 37 | + imports { |
| 38 | + mavenBom "io.opencensus:opencensus-contrib-spring-starter:0.23.0" |
| 39 | + } |
| 40 | +} |
| 41 | +dependencies { |
| 42 | + compile 'io.opencensus:opencensus-contrib-spring:0.23.0' |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +### Tracing Properties |
| 47 | + |
| 48 | +Optionally configure one or more Tracing Properties in application.properties file. |
| 49 | + |
| 50 | + |
| 51 | +#### PublicEndpoint |
| 52 | + |
| 53 | +If a servlet is serving publicEndpoints (untrusted boundary) then set this property to `true`. |
| 54 | +When set to true incoming trace context is added as a parent link instead of as a parent. |
| 55 | +By default it is set to `false`. When set to `false` it uses incoming trace context as a parent. |
| 56 | + |
| 57 | +``` |
| 58 | +opencensus.spring.trace.publicEndpoint = true |
| 59 | +``` |
| 60 | + |
| 61 | +#### Propagation |
| 62 | + |
| 63 | +opencensus.spring.trace.propagation = TRACE_PROPAGATION_B3 |
| 64 | + |
| 65 | +By default it is set to TRACE_PROPAGATION_TRACE_CONTEXT which uses [W3C Tracecontext](https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/trace/propagation/TextFormat.java) |
| 66 | +propagator to propagate trace context. To use [B3 format](https://github.com/census-instrumentation/opencensus-java/blob/master/impl_core/src/main/java/io/opencensus/implcore/trace/propagation/B3Format.java) |
| 67 | +set the property to TRACE_PROPAGATION_B3 |
| 68 | + |
| 69 | +``` |
| 70 | +opencensus.spring.trace.propagation = TRACE_PROPAGATION_B3 |
| 71 | +``` |
| 72 | + |
| 73 | +#### Java Versions |
| 74 | + |
| 75 | +Java 6 or above is required for using this artifact. |
| 76 | + |
| 77 | +[travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master |
| 78 | +[travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java |
| 79 | +[appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true |
| 80 | +[appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master |
| 81 | +[maven-image]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-spring-starter/badge.svg |
| 82 | +[maven-url]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-spring-starter |
| 83 | +[spring-boot-2.0-url]: https://github.com/spring-projects/spring-boot/tree/2.0.x |
| 84 | +[spring-web-url]: https://github.com/spring-projects/spring-framework/tree/master/spring-web |
0 commit comments