diff options
| author | Bogdan Drutu <bdrutu@google.com> | 2017-03-11 12:21:17 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-11 12:21:17 -0800 |
| commit | 0337f5973b47bff878d2231efa79421189cb423f (patch) | |
| tree | 0ce6397a9062fe7ea738319b7d4c741482e493f1 /examples | |
| parent | cf0cee8f5519f6186241dbdda0defcddd4977b49 (diff) | |
| download | platform_external_opencensus-java-0337f5973b47bff878d2231efa79421189cb423f.tar.gz platform_external_opencensus-java-0337f5973b47bff878d2231efa79421189cb423f.tar.bz2 platform_external_opencensus-java-0337f5973b47bff878d2231efa79421189cb423f.zip | |
Remove the try-with-resources support for the Span. This is important because we want to discourage the usage of the Span and encourage the usage of ScopedSpan. (#127)
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/src/main/java/com/google/instrumentation/trace/BasicTracing.java | 6 | ||||
| -rw-r--r-- | examples/src/main/java/com/google/instrumentation/trace/MultiSpansTracing.java | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/examples/src/main/java/com/google/instrumentation/trace/BasicTracing.java b/examples/src/main/java/com/google/instrumentation/trace/BasicTracing.java index edd1e7e0..bdb57680 100644 --- a/examples/src/main/java/com/google/instrumentation/trace/BasicTracing.java +++ b/examples/src/main/java/com/google/instrumentation/trace/BasicTracing.java @@ -19,9 +19,9 @@ public final class BasicTracing { private static final Tracer tracer = Tracer.getTracer(); private static void doWork() { - try (Span span = tracer.spanBuilder(null, "MyRootSpan").startSpan()) { - span.addAnnotation("This annotation is added directly to the span."); - } + Span span = tracer.spanBuilder(null, "MyRootSpan").startSpan(); + span.addAnnotation("This annotation is added directly to the span."); + span.end(); } public static void main(String[] args) { diff --git a/examples/src/main/java/com/google/instrumentation/trace/MultiSpansTracing.java b/examples/src/main/java/com/google/instrumentation/trace/MultiSpansTracing.java index 74b017cd..56d6bfe5 100644 --- a/examples/src/main/java/com/google/instrumentation/trace/MultiSpansTracing.java +++ b/examples/src/main/java/com/google/instrumentation/trace/MultiSpansTracing.java @@ -19,13 +19,13 @@ public final class MultiSpansTracing { private static final Tracer tracer = Tracer.getTracer(); private static void doWork() { - try (Span rootSpan = tracer.spanBuilder(null, "MyRootSpan").startSpan()) { - rootSpan.addAnnotation("Annotation to the root Span before child is created."); - try (Span childSpan = tracer.spanBuilder(rootSpan, "MyChildSpan").startSpan()) { - childSpan.addAnnotation("Annotation to the child Span"); - } - rootSpan.addAnnotation("Annotation to the root Span after child is ended."); - } + Span rootSpan = tracer.spanBuilder(null, "MyRootSpan").startSpan(); + rootSpan.addAnnotation("Annotation to the root Span before child is created."); + Span childSpan = tracer.spanBuilder(rootSpan, "MyChildSpan").startSpan(); + childSpan.addAnnotation("Annotation to the child Span"); + childSpan.end(); + rootSpan.addAnnotation("Annotation to the root Span after child is ended."); + rootSpan.end(); } public static void main(String[] args) { |
