aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorsavaki <matt.ho@gmail.com>2018-07-18 07:42:19 -0700
committersavaki <matt.ho@gmail.com>2018-07-21 07:44:40 -0700
commit3dcabd02cf06b303d7e109608974a635f61fd6c8 (patch)
tree8423fe350787a08e3c9aab4007758d147929f914 /contrib
parent542abc9030bce4daafda5742feefa7fa7c7454c0 (diff)
downloadplatform_external_opencensus-java-3dcabd02cf06b303d7e109608974a635f61fd6c8.tar.gz
platform_external_opencensus-java-3dcabd02cf06b303d7e109608974a635f61fd6c8.tar.bz2
platform_external_opencensus-java-3dcabd02cf06b303d7e109608974a635f61fd6c8.zip
updated spring README.md
Diffstat (limited to 'contrib')
-rw-r--r--contrib/spring/README.md85
1 files changed, 70 insertions, 15 deletions
diff --git a/contrib/spring/README.md b/contrib/spring/README.md
index 4e2ad8f2..e33a4274 100644
--- a/contrib/spring/README.md
+++ b/contrib/spring/README.md
@@ -16,17 +16,17 @@ For Maven add to your `pom.xml`:
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
- <version>0.15.0</version>
+ <version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-contrib-spring</artifactId>
- <version>0.15.0</version>
+ <version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-impl</artifactId>
- <version>0.15.0</version>
+ <version>0.16.0</version>
<scope>runtime</scope>
</dependency>
@@ -43,31 +43,86 @@ For Maven add to your `pom.xml`:
For Gradle add to your dependencies:
```gradle
-compile 'io.opencensus:opencensus-api:0.15.0'
-compile 'io.opencensus:opencensus-contrib-spring:0.15.0'
-runtime 'io.opencensus:opencensus-impl:0.15.0'
+compile 'io.opencensus:opencensus-api:c'
+compile 'io.opencensus:opencensus-contrib-spring:0.16.0'
+runtime 'io.opencensus:opencensus-impl:0.16.0'
runtime 'org.springframework:spring-aspects:SPRING_VERSION'
```
-### Configure Spring
+### Features
-To configure annotation support within Spring, include the following with your
-spring xml configuration.
+#### @Traced Annotation
+
+The `opencensus-contrib-spring` package provides support for a `@Traced` annotation
+that can be applied to methods. When applied, the method will be wrapped in a
+Span, [https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/Span.md](https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/Span.md)
+
+If the method throws an exception, the `Span` will be marked with a status of `Status.UNKNOWN`
+and the stack trace will be added to the span as an annotation.
+
+To enable the `@Traced` annotation, include the `CensusSpringAspect` bean.
+
+```xml
+ <!-- traces explicit calls to @Traced -->
+ <bean id="censusAspect" class="io.opencensus.contrib.spring.aop.CensusSpringAspect">
+ <constructor-arg ref="tracer"/>
+ </bean>
+```
+
+#### Database Support
+
+The `opencensus-contrib-spring` package also includes support for tracing database
+calls. When database support is included, all calls to `java.sql.PreparedStatement.execute*`
+will be wrapped in a Span in the same way that `@Traced` wraps methods.
+
+To enable database support, include the `CensusSpringSqlAspect` bean.
```xml
- <!-- Enable @AspectJ annotation support -->
+ <!-- traces all SQL calls -->
+ <bean id="censusSQLAspect" class="io.opencensus.contrib.spring.aop.CensusSpringSqlAspect">
+ <constructor-arg ref="tracer"/>
+ </bean>
+```
+
+#### Complete Spring XML configuration
+
+The following contains a complete spring xml file to configure `opencensus-contrib-spring`
+with support for both `@Traced` and database connection tracing.
+
+**Note:** This example does not include the configuration of any exporters. That will
+need to be done separately.
+
+**TBD:*** Include examples of spring with exporters.
+
+```xml
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
+
<aop:aspectj-autoproxy/>
<!-- traces explicit calls to @Traced -->
- <bean id="censusAspect" class="io.opencensus.contrib.spring.aop.CensusSpringAspect"/>
+ <bean id="censusAspect" class="io.opencensus.contrib.spring.aop.CensusSpringAspect">
+ <constructor-arg ref="tracer"/>
+ </bean>
<!-- traces all SQL calls -->
- <bean id="censusSQLAspect" class="io.opencensus.contrib.spring.aop.CensusSpringSQLAspect"/>
+ <bean id="censusSQLAspect" class="io.opencensus.contrib.spring.aop.CensusSpringSqlAspect">
+ <constructor-arg ref="tracer"/>
+ </bean>
+
+ <!-- global tracer -->
+ <bean id="tracer" class="io.opencensus.trace.Tracing" factory-method="getTracer"/>
+</beans>
```
-### Usage
+### @Traced Usage
-Once configured, you can use the `@Traced` annotation to indicate that a method should be traces.
+Once configured, you can use the `@Traced` annotation to indicate that a method should
+be wrapped with a `Span`. By default, `@Traced` will use the name of the method as the
+span name. However, `@Traced` supports an optional name attribute to allow a custom
+span name to be specified.
```java
@Traced()
@@ -84,7 +139,7 @@ Once configured, you can use the `@Traced` annotation to indicate that a method
#### Notes
-Spring support only enables annotations. You'll still need to configure opencensus and register exporters / views.
+`opencensus-contrib-spring` support only enables annotations. You will still need to configure opencensus and register exporters / views.
[travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master
[travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java