Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit cae53ac

Browse files
addressing comments in #13
1 parent fd5564d commit cae53ac

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

opentracing/src/main/java/opentracing/Span.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
package opentracing;
1515

1616
/**
17-
* Span represents an active, un-finished span in the opentracing system.
17+
* Represents an in-flight span in the opentracing system.
1818
*
19-
* <p>Spans are created by the {@link Tracer} interface.
19+
* <p>Spans are created by the {@link Tracer#buildSpan} interface.
2020
*/
2121
public interface Span {
2222

@@ -30,13 +30,6 @@ public interface Span {
3030

3131
/**
3232
* Set a key:value tag on the Span.
33-
*
34-
* <p>Tag values can be of arbitrary types, however the treatment of complex types is dependent on
35-
* the underlying tracing system implementation. It is expected that most tracing systems will
36-
* handle primitive types like strings and numbers. If a tracing system cannot understand how to
37-
* handle a particular value type, it may ignore the tag, but shall not panic.
38-
*
39-
* <p>If there is a pre-existing tag set for {@code key}, it is overwritten.
4033
*/
4134
// overloaded 3x to support the BasicType concern
4235
Span setTag(String key, String value);
@@ -54,10 +47,13 @@ public interface Span {
5447
*/
5548
Span setBaggageItem(String key, String value);
5649

57-
/** Get a Baggage item by key. */
50+
/** Get a Baggage item by key.
51+
*
52+
* Returns null if no entry found, or baggage is not supported in the current implementation.
53+
*/
5854
String getBaggageItem(String key);
5955

60-
/** *
56+
/**
6157
* Add a new log event to the Span, accepting an event name string and an optional structured payload argument.
6258
* If specified, the payload argument may be of any type and arbitrary size,
6359
* though implementations are not required to retain all payload arguments
@@ -76,5 +72,5 @@ public interface Span {
7672
* The timestamp is specified manually here to represent a past log event.
7773
* The timestamp in microseconds in UTC time.
7874
**/
79-
Span log(long instantMicroseconds, String eventName, /* @Nullable */ Object payload);
75+
Span log(long timestampMicroseconds, String eventName, /* @Nullable */ Object payload);
8076
}

opentracing/src/main/java/opentracing/Tracer.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public interface Tracer {
4343
* a Span instance, and
4444
* a “carrier” object in which to inject that Span for cross-process propagation.
4545
*
46+
* A “carrier” object is some sort of http or rpc envelope, for example HeaderGroup (from Apache HttpComponents).
47+
*
48+
* The low-level format carriers Map&lt;String,String&gt; and ByteBuffer are guaranteed to be supported,
49+
* otherwise only carriers that have been registered are supported.
50+
*
51+
* Attempting to inject to a carrier that has been registered/configured to this Tracer will result in a
52+
* IllegalStateException.
4653
*/
4754
<T> void inject(Span span, T carrier);
4855

@@ -56,9 +63,16 @@ public interface Tracer {
5663
*
5764
* (Note that some OpenTracing implementations consider the Spans on either side of an RPC to have the same identity,
5865
* and others consider the caller to be the parent and the receiver to be the child)
66+
*
67+
* Attempting to join from a carrier that has been registered/configured to this Tracer will result in a
68+
* IllegalStateException.
69+
*
70+
* If the span serialized state is invalid (corrupt, wrong version, etc) inside the carrier this will result in a
71+
* IllegalArgumentException.
5972
*/
6073
<T> SpanBuilder join(T carrier);
6174

75+
6276
interface SpanBuilder {
6377

6478
/** Specify the operationName.
@@ -73,12 +87,6 @@ interface SpanBuilder {
7387
*/
7488
SpanBuilder withParent(Span parent);
7589

76-
/** Specify a timestamp the Span actually started from.
77-
*
78-
* If the timestamp has already been set an IllegalStateException will be thrown.
79-
*/
80-
SpanBuilder withTimestamp(long microseconds);
81-
8290
/** Same as {@link Span#setTag(String, String)}, but for the span being built. */
8391
SpanBuilder withTag(String key, String value);
8492

@@ -88,7 +96,13 @@ interface SpanBuilder {
8896
/** Same as {@link Span#setTag(String, String)}, but for the span being built. */
8997
SpanBuilder withTag(String key, Number value);
9098

99+
/** Specify a timestamp of when the Span was started, represented in microseconds since epoch. */
100+
SpanBuilder withStartTimestamp(long microseconds);
101+
91102
/** Returns the started Span. */
92103
Span start();
104+
105+
/** Returns the Span, with a started timestamp (represented in microseconds) as specified. */
106+
Span start(long microseconds);
93107
}
94108
}

0 commit comments

Comments
 (0)