diff options
| author | Yang Song <songy23@users.noreply.github.com> | 2018-04-02 16:49:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-02 16:49:22 -0700 |
| commit | efa417a224f1493e24207a92957d8e081f73e1d2 (patch) | |
| tree | 7565b9edea464f0d7e42c33f74973c8caadf79e4 /README.md | |
| parent | 081e14275713fdeb55488fcb3eb920378d92590d (diff) | |
| download | platform_external_opencensus-java-efa417a224f1493e24207a92957d8e081f73e1d2.tar.gz platform_external_opencensus-java-efa417a224f1493e24207a92957d8e081f73e1d2.tar.bz2 platform_external_opencensus-java-efa417a224f1493e24207a92957d8e081f73e1d2.zip | |
Update README based on customers' feedback (#1109)
* Update tracing code snippet.
* Fix a TODO.
* Explain why to set record events and sampler.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -19,7 +19,7 @@ project. Integrating OpenCensus with a new library means recording stats or traces and propagating context. -TODO: add a link to Java quick start documentation on opencensus.io once it's ready. +The full quick start example can also be found on the [OpenCensus website](https://opencensus.io/java.html). ### Add the dependencies to your project @@ -50,8 +50,14 @@ public final class MyClassWithTracing { private static final Tracer tracer = Tracing.getTracer(); public static void doWork() { - // Create a child Span of the current Span. - try (Scope ss = tracer.spanBuilder("MyChildWorkSpan").startScopedSpan()) { + // Create a child Span of the current Span. Always record events for this span and force it to + // be sampled. This makes it easier to try out the example, but unless you have a clear use + // case, you don't need to explicitly set record events or sampler. + try (Scope ss = + tracer.spanBuilder("MyChildWorkSpan") + .setRecordEvents(true) + .setSampler(Samplers.alwaysSample()) + .startScopedSpan()) { doInitialWork(); tracer.getCurrentSpan().addAnnotation("Finished initial work"); doFinalWork(); |
