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

Commit

Permalink
Remove TraceContext, as has already been done in the specification.
Browse files Browse the repository at this point in the history
Remove TraceContextSource, as methods from it now belong in Tracer.
Remove Tracer.joinTrace(..) as Span.startChild(..) already does this.

ref:
 - opentracing/opentracing.io#42
 - #7
  • Loading branch information
michaelsembwever committed Feb 2, 2016
1 parent 53fb140 commit 60d9019
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 152 deletions.
7 changes: 2 additions & 5 deletions opentracing/src/main/java/opentracing/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
*/
public interface Span {

/**
* Suitable for serializing over the wire, etc.
*/
TraceContext traceContext();

/**
* Denotes the beginning of a subordinate unit of work.
*
Expand Down Expand Up @@ -64,6 +59,8 @@ public interface Span {
// numbers kindof suck.. we've no idea if this is a float, how many bits, etc.
Span setTag(String key, Number value);

Span setTraceAttribute(String key, String value);

/**
* {@code message} is a format string and can refer to fields in the payload by path, like so:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,25 @@
import java.util.Map;

/**
* Encodes or Decodes a {@linkplain TraceContext trace context} in binary or text formats.
* Encodes or Decodes a {@linkplain Span span} in binary or text formats.
*
* <p>The toXXX methods are expected to serialize trace contexts into a pair of values representing
* separately the trace context / span identity, and the trace attributes. This is done specifically
* for binary protocols that may represent tracing identity in a dedicated fixed-length slot in the
* <p>The toXXX methods are expected to serialize spans into a pair of values representing
* separately the span / span identity, and the trace attributes.
*
* This is done specifically for binary protocols that may represent tracing identity in a dedicated fixed-length slot in the
* binary message format, so that it can be inspected efficiently by the middleware / routing layers
* without parsing the whole message.
*/
public interface TraceContextCodec {
public interface SpanPropagator {

/**
* Implementation-specific format of a span's identity along with any trace attributes.
*
* @param <E> encoding, for example {@code byte[]} for binary, or {@code Map<String, String>} for
* text.
*/
// Can instead explicitly create BinaryEncodedTraceContext, TextEncodedTraceContext, just.. cluttery
interface EncodedTraceContext<E> {
// Can instead explicitly create BinaryEncodedSpan, TextEncodedSpan, just.. cluttery
interface EncodedSpan<E> {
/** Encoded span identifier. */
E spanIdentity();

Expand All @@ -42,30 +43,30 @@ interface EncodedTraceContext<E> {
}

/**
* Encodes the trace context into a binary representation of the span's identity and trace
* Encodes the span into a binary representation of the span's identity and trace
* attributes.
*/
EncodedTraceContext<byte[]> toBinary(TraceContext tc);
EncodedSpan<byte[]> toBinary(Span tc);

/**
* Decodes a trace context from a binary representation of the span's identity and trace
* Decodes a span from a binary representation of the span's identity and trace
* attributes.
*
* @throws IllegalArgumentException if the encoded data is malformed.
*/
TraceContext fromBinary(EncodedTraceContext<byte[]> encoded);
Span fromBinary(EncodedSpan<byte[]> encoded);

/**
* Encodes the trace context into a text representation of the span's identity and trace
* Encodes the span into a text representation of the span's identity and trace
* attributes.
*/
EncodedTraceContext<Map<String, String>> toText(TraceContext tc);
EncodedSpan<Map<String, String>> toText(Span tc);

/**
* Decodes a trace context from a text representation of the span's identity and trace
* Decodes a span from a text representation of the span's identity and trace
* attributes.
*
* @throws IllegalArgumentException if the encoded data is malformed.
*/
TraceContext fromText(EncodedTraceContext<Map<String, String>> encoded);
Span fromText(EncodedSpan<Map<String, String>> encoded);
}
66 changes: 0 additions & 66 deletions opentracing/src/main/java/opentracing/TraceContext.java

This file was deleted.

48 changes: 0 additions & 48 deletions opentracing/src/main/java/opentracing/TraceContextSource.java

This file was deleted.

19 changes: 1 addition & 18 deletions opentracing/src/main/java/opentracing/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,5 @@ public interface Tracer {
*/
Span startTrace(String operationName);

/**
* Like {@link #startTrace(String)}, but the returned span is made a child of {@code parent}.
*/
Span joinTrace(String operationName, TraceContext parent);

/**
* StartSpanWithContext returns a span with the given {@code operationName} and an association
* with {@code context} (rather than creating a fresh root context like {@link
* #startTrace(String)} or a fresh child context like {@link #joinTrace(String, TraceContext)}).
*
* <p>Note that the following calls are equivalent
* <pre>{@code
* Span feed = tracer.startSpanWithContext("GetFeed", traceContextSource.newRoot());
* ...
* Span feed = tracer.startTrace("GetFeed");
* }</pre>
*/
Span startSpanWithContext(String operationName, TraceContext context);
SpanPropagator getSpanPropagator();
}

0 comments on commit 60d9019

Please sign in to comment.