Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
src/main/resources/META-INF/ | H | 25-Apr-2025 | - | 1 | 1 | |
README.md | H A D | 25-Apr-2025 | 3.1 KiB | 85 | 61 | |
build.gradle | H A D | 25-Apr-2025 | 397 | 19 | 14 |
README.md
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 6The *OpenCensus Spring Starter for Java* is a starter package that includes 7packages required to enable tracing using opencensus when working with [Spring Web][spring-web-url]. 8 9This version is compatible with [Spring Boot 2.0][spring-boot-2.0-url]. 10 11## Servlet and AsyncRestTemplate Tracing 12 13Enable tracing on RestController (server side) and AysncRestTemplate (client side) by simply including opencensus-contrib-spring-starter in your dependencies and 14initializing exporter. It automatically traces your http request and collects stats associated with the 15request. 16 17It 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 36dependencyManagement { 37 imports { 38 mavenBom "io.opencensus:opencensus-contrib-spring-starter:0.23.0" 39 } 40} 41dependencies { 42 compile 'io.opencensus:opencensus-contrib-spring:0.23.0' 43} 44``` 45 46### Tracing Properties 47 48Optionally configure one or more Tracing Properties in application.properties file. 49 50 51#### PublicEndpoint 52 53If a servlet is serving publicEndpoints (untrusted boundary) then set this property to `true`. 54When set to true incoming trace context is added as a parent link instead of as a parent. 55By default it is set to `false`. When set to `false` it uses incoming trace context as a parent. 56 57``` 58opencensus.spring.trace.publicEndpoint = true 59``` 60 61#### Propagation 62 63opencensus.spring.trace.propagation = TRACE_PROPAGATION_B3 64 65By 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) 66propagator 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) 67set the property to TRACE_PROPAGATION_B3 68 69``` 70opencensus.spring.trace.propagation = TRACE_PROPAGATION_B3 71``` 72 73#### Java Versions 74 75Java 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 85