From 7bc6ae10c9302b9e001ce2996424b743006f5013 Mon Sep 17 00:00:00 2001 From: mck Date: Thu, 3 Mar 2016 17:29:58 +1100 Subject: [PATCH] addressing comments in https://github.com/opentracing/opentracing-java/pull/13 --- .../src/main/java/opentracing/Span.java | 20 +++++++--------- .../src/main/java/opentracing/Tracer.java | 23 ++++++++++++++----- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/opentracing/src/main/java/opentracing/Span.java b/opentracing/src/main/java/opentracing/Span.java index 8269a8af..6b55eff8 100644 --- a/opentracing/src/main/java/opentracing/Span.java +++ b/opentracing/src/main/java/opentracing/Span.java @@ -14,9 +14,9 @@ package opentracing; /** - * Span represents an active, un-finished span in the opentracing system. + * Represents an in-flight span in the opentracing system. * - *

Spans are created by the {@link Tracer} interface. + *

Spans are created by the {@link Tracer#buildSpan} interface. */ public interface Span { @@ -30,13 +30,6 @@ public interface Span { /** * Set a key:value tag on the Span. - * - *

Tag values can be of arbitrary types, however the treatment of complex types is dependent on - * the underlying tracing system implementation. It is expected that most tracing systems will - * handle primitive types like strings and numbers. If a tracing system cannot understand how to - * handle a particular value type, it may ignore the tag, but shall not panic. - * - *

If there is a pre-existing tag set for {@code key}, it is overwritten. */ // overloaded 3x to support the BasicType concern Span setTag(String key, String value); @@ -54,10 +47,13 @@ public interface Span { */ Span setBaggageItem(String key, String value); - /** Get a Baggage item by key. */ + /** Get a Baggage item by key. + * + * Returns null if no entry found, or baggage is not supported in the current implementation. + */ String getBaggageItem(String key); - /** * + /** * Add a new log event to the Span, accepting an event name string and an optional structured payload argument. * If specified, the payload argument may be of any type and arbitrary size, * though implementations are not required to retain all payload arguments @@ -76,5 +72,5 @@ public interface Span { * The timestamp is specified manually here to represent a past log event. * The timestamp in microseconds in UTC time. **/ - Span log(long instantMicroseconds, String eventName, /* @Nullable */ Object payload); + Span log(long timestampMicroseconds, String eventName, /* @Nullable */ Object payload); } diff --git a/opentracing/src/main/java/opentracing/Tracer.java b/opentracing/src/main/java/opentracing/Tracer.java index 7d66f5a9..6390eea6 100644 --- a/opentracing/src/main/java/opentracing/Tracer.java +++ b/opentracing/src/main/java/opentracing/Tracer.java @@ -43,6 +43,10 @@ public interface Tracer { * a Span instance, and * a “carrier” object in which to inject that Span for cross-process propagation. * + * A “carrier” object is some sort of http or rpc envelope, for example HeaderGroup (from Apache HttpComponents). + * + * Attempting to inject to a carrier that has been registered/configured to this Tracer will result in a + * IllegalStateException. */ void inject(Span span, T carrier); @@ -56,9 +60,16 @@ public interface Tracer { * * (Note that some OpenTracing implementations consider the Spans on either side of an RPC to have the same identity, * and others consider the caller to be the parent and the receiver to be the child) + * + * Attempting to join from a carrier that has been registered/configured to this Tracer will result in a + * IllegalStateException. + * + * If the span serialized state is invalid (corrupt, wrong version, etc) inside the carrier this will result in a + * IllegalArgumentException. */ SpanBuilder join(T carrier); + interface SpanBuilder { /** Specify the operationName. @@ -73,12 +84,6 @@ interface SpanBuilder { */ SpanBuilder withParent(Span parent); - /** Specify a timestamp the Span actually started from. - * - * If the timestamp has already been set an IllegalStateException will be thrown. - */ - SpanBuilder withTimestamp(long microseconds); - /** Same as {@link Span#setTag(String, String)}, but for the span being built. */ SpanBuilder withTag(String key, String value); @@ -88,7 +93,13 @@ interface SpanBuilder { /** Same as {@link Span#setTag(String, String)}, but for the span being built. */ SpanBuilder withTag(String key, Number value); + /** Specify a timestamp of when the Span was started, represented in microseconds since epoch. */ + SpanBuilder withStartTimestamp(long microseconds); + /** Returns the started Span. */ Span start(); + + /** Returns the Span, with a started timestamp (represented in microseconds) as specified. */ + Span start(long microseconds); } }