diff options
| author | rghetia <rahulpa@google.com> | 2019-06-11 17:26:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-11 17:26:30 -0700 |
| commit | f0c0ca275831c405a80c279b063916f7850fcbea (patch) | |
| tree | cff947669b095c9ee2040daae4cdc939d3a29628 /contrib | |
| parent | bf0fad4fe4dcc5aee5108cbf718923e38ed7dbb0 (diff) | |
| download | platform_external_opencensus-java-f0c0ca275831c405a80c279b063916f7850fcbea.tar.gz platform_external_opencensus-java-f0c0ca275831c405a80c279b063916f7850fcbea.tar.bz2 platform_external_opencensus-java-f0c0ca275831c405a80c279b063916f7850fcbea.zip | |
add spring starter package for opencensus spring integration. (#1934)
* add spring starter package for opencensus spring integration.
* remove duplicate links.
* fix build error.
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/spring_starter/README.md | 84 | ||||
| -rw-r--r-- | contrib/spring_starter/build.gradle | 18 | ||||
| -rw-r--r-- | contrib/spring_starter/src/main/resources/META-INF/spring.provides | 1 |
3 files changed, 103 insertions, 0 deletions
diff --git a/contrib/spring_starter/README.md b/contrib/spring_starter/README.md new file mode 100644 index 00000000..495de562 --- /dev/null +++ b/contrib/spring_starter/README.md @@ -0,0 +1,84 @@ +# OpenCensus Spring Starter +[![Build Status][travis-image]][travis-url] +[![Windows Build Status][appveyor-image]][appveyor-url] +[![Maven Central][maven-image]][maven-url] + +The *OpenCensus Spring Starter for Java* is a starter package that includes +packages required to enable tracing using opencensus when working with [Spring Web][spring-web-url]. + +This version is compatible with [Spring Boot 2.0][spring-boot-2.0-url]. + +## Servlet and AsyncRestTemplate Tracing + +Enable tracing on RestController (server side) and AysncRestTemplate (client side) by simply including opencensus-contrib-spring-starter in your dependencies and +initializing exporter. It automatically traces your http request and collects stats associated with the +request. + +It does require to register exporter and views. + +### Depedencies + +#### Maven + +```xml +<dependencies> + <dependency> + <groupId>io.opencensus</groupId> + <artifactId>opencensus-contrib-spring-starter</artifactId> + <version>0.23.0</version> + </dependency> +</dependencies> + +``` + +#### Gradle +```gradle +dependencyManagement { + imports { + mavenBom "io.opencensus:opencensus-contrib-spring-starter:0.23.0" + } +} +dependencies { + compile 'io.opencensus:opencensus-contrib-spring:0.23.0' +} +``` + +### Tracing Properties + +Optionally configure one or more Tracing Properties in application.properties file. + + +#### PublicEndpoint + +If a servlet is serving publicEndpoints (untrusted boundary) then set this property to `true`. +When set to true incoming trace context is added as a parent link instead of as a parent. +By default it is set to `false`. When set to `false` it uses incoming trace context as a parent. + +``` +opencensus.spring.trace.publicEndpoint = true +``` + +#### Propagation + +opencensus.spring.trace.propagation = TRACE_PROPAGATION_B3 + +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) +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) +set the property to TRACE_PROPAGATION_B3 + +``` +opencensus.spring.trace.propagation = TRACE_PROPAGATION_B3 +``` + +#### Java Versions + +Java 6 or above is required for using this artifact. + +[travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master +[travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java +[appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true +[appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master +[maven-image]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-spring-starter/badge.svg +[maven-url]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-spring-starter +[spring-boot-2.0-url]: https://github.com/spring-projects/spring-boot/tree/2.0.x +[spring-web-url]: https://github.com/spring-projects/spring-framework/tree/master/spring-web diff --git a/contrib/spring_starter/build.gradle b/contrib/spring_starter/build.gradle new file mode 100644 index 00000000..96691a74 --- /dev/null +++ b/contrib/spring_starter/build.gradle @@ -0,0 +1,18 @@ +plugins { + id 'java' +} + +description = 'OpenCensus Spring Cloud Starter' + +[compileJava, compileTestJava].each() { + it.sourceCompatibility = 1.6 + it.targetCompatibility = 1.6 +} + +dependencies { + compile project(':opencensus-api'), + project(':opencensus-contrib-spring'), + project(':opencensus-impl') + + signature "org.codehaus.mojo.signature:java16:+@signature" +} diff --git a/contrib/spring_starter/src/main/resources/META-INF/spring.provides b/contrib/spring_starter/src/main/resources/META-INF/spring.provides new file mode 100644 index 00000000..ffe5e4d4 --- /dev/null +++ b/contrib/spring_starter/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: opencensus-contrib-spring
\ No newline at end of file |
