From 8a5cadbbbda20a7bae288549b1aac7f77a989a68 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 13 Mar 2017 20:56:37 -0700 Subject: Fix comments after PR/126 & PR/127 (#134) * Fix comments after PR/126 * Fix comments after PR/127 --- .../java/com/google/instrumentation/trace/SpanBuilder.java | 13 ++++++++----- .../main/java/com/google/instrumentation/trace/SpanId.java | 9 ++++----- .../main/java/com/google/instrumentation/trace/TraceId.java | 9 ++++----- 3 files changed, 16 insertions(+), 15 deletions(-) (limited to 'core') diff --git a/core/src/main/java/com/google/instrumentation/trace/SpanBuilder.java b/core/src/main/java/com/google/instrumentation/trace/SpanBuilder.java index 07fcde75..0c234cea 100644 --- a/core/src/main/java/com/google/instrumentation/trace/SpanBuilder.java +++ b/core/src/main/java/com/google/instrumentation/trace/SpanBuilder.java @@ -29,12 +29,15 @@ import javax.annotation.Nullable; *
{@code
  * class MyClass {
  *   private static final Tracer tracer = Tracer.getTracer();
- *   void doWork(Span parent) {
- *     // Create a Span as a child of the given parent.
- *     Span span = tracer.spanBuilder(parent, "MyChildSpan").startSpan();
+ *   void DoWork() {
+ *     Span span = tracer.spanBuilder(null, "MyRootSpan").startSpan();
  *     span.addAnnotation("my annotation");
- *     doSomeWork(span); // Manually propagate the new span down the stack.
- *     span.end();  // Manually end the span.
+ *     try {
+ *       doSomeWork(span); // Manually propagate the new span down the stack.
+ *     } finally {
+ *       // To make sure we end the span even in case of an exception.
+ *       span.end();  // Manually end the span.
+ *     }
  *   }
  * }
  * }
diff --git a/core/src/main/java/com/google/instrumentation/trace/SpanId.java b/core/src/main/java/com/google/instrumentation/trace/SpanId.java index 9732a4c8..70ed6a14 100644 --- a/core/src/main/java/com/google/instrumentation/trace/SpanId.java +++ b/core/src/main/java/com/google/instrumentation/trace/SpanId.java @@ -23,7 +23,7 @@ import java.util.Random; import javax.annotation.concurrent.Immutable; /** - * A class that represents a span identifier. A valid span identifier is a 8-bytes array with + * A class that represents a span identifier. A valid span identifier is an 8-byte array with * at least one non-zero byte. */ @Immutable @@ -80,7 +80,7 @@ public final class SpanId implements Comparable { /** - * Returns whether the span identifier is valid. A valid span identifier is a 8-bytes array with + * Returns whether the span identifier is valid. A valid span identifier is an 8-byte array with * at least one non-zero byte. * * @return {@code true} if the span identifier is valid. @@ -120,10 +120,9 @@ public final class SpanId implements Comparable { @Override public int compareTo(SpanId that) { for (int i = 0; i < SPAN_ID_SIZE; i++) { - if (bytes[i] == that.bytes[i]) { - continue; + if (bytes[i] != that.bytes[i]) { + return bytes[i] < that.bytes[i] ? -1 : 1; } - return bytes[i] < that.bytes[i] ? -1 : 1; } return 0; } diff --git a/core/src/main/java/com/google/instrumentation/trace/TraceId.java b/core/src/main/java/com/google/instrumentation/trace/TraceId.java index b33a7ace..20d2e108 100644 --- a/core/src/main/java/com/google/instrumentation/trace/TraceId.java +++ b/core/src/main/java/com/google/instrumentation/trace/TraceId.java @@ -23,7 +23,7 @@ import java.util.Random; import javax.annotation.concurrent.Immutable; /** - * A class that represents a trace identifier. A valid trace identifier is a 16-bytes array with + * A class that represents a trace identifier. A valid trace identifier is a 16-byte array with * at least one non-zero byte. */ @Immutable @@ -79,7 +79,7 @@ public final class TraceId implements Comparable { } /** - * Returns whether the {@code TraceId} is valid. A valid trace identifier is a 16-bytes array with + * Returns whether the {@code TraceId} is valid. A valid trace identifier is a 16-byte array with * at least one non-zero byte. * * @return {@code true} if the {@code TraceId} is valid. @@ -119,10 +119,9 @@ public final class TraceId implements Comparable { @Override public int compareTo(TraceId that) { for (int i = 0; i < TRACE_ID_SIZE; i++) { - if (bytes[i] == that.bytes[i]) { - continue; + if (bytes[i] != that.bytes[i]) { + return bytes[i] < that.bytes[i] ? -1 : 1; } - return bytes[i] < that.bytes[i] ? -1 : 1; } return 0; } -- cgit v1.2.3