diff options
author | Bogdan Drutu <bdrutu@google.com> | 2018-05-31 18:56:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 18:56:17 -0700 |
commit | 55c12779e8a17e0d3d3e88480a01857f051cae55 (patch) | |
tree | 6497571af06fc83ce18ff8cd29e5e972553f5599 /impl_core/src/main/java/io/opencensus | |
parent | 8adb02c12daef7512dc26ea7f05889804a111be2 (diff) | |
download | opencensus-java-55c12779e8a17e0d3d3e88480a01857f051cae55.tar.gz |
Add Span.Kind to the trace API. (#1223)
* Add Span.Kind to the trace API.
* Add @Nullable annotation where needed.
* Add changes to changelog.
Diffstat (limited to 'impl_core/src/main/java/io/opencensus')
-rw-r--r-- | impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java | 11 | ||||
-rw-r--r-- | impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java index 45cf4261..f5d74393 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java @@ -25,6 +25,7 @@ import io.opencensus.trace.Link; import io.opencensus.trace.Link.Type; import io.opencensus.trace.Sampler; import io.opencensus.trace.Span; +import io.opencensus.trace.Span.Kind; import io.opencensus.trace.SpanBuilder; import io.opencensus.trace.SpanContext; import io.opencensus.trace.SpanId; @@ -48,6 +49,7 @@ final class SpanBuilderImpl extends SpanBuilder { @Nullable private Sampler sampler; private List<Span> parentLinks = Collections.<Span>emptyList(); @Nullable private Boolean recordEvents; + @Nullable private Kind kind; private SpanImpl startSpanInternal( @Nullable SpanContext parent, @@ -56,6 +58,7 @@ final class SpanBuilderImpl extends SpanBuilder { @Nullable Sampler sampler, List<Span> parentLinks, @Nullable Boolean recordEvents, + @Nullable Kind kind, @Nullable TimestampConverter timestampConverter) { TraceParams activeTraceParams = options.traceConfig.getActiveTraceParams(); Random random = options.randomHandler.current(); @@ -95,6 +98,7 @@ final class SpanBuilderImpl extends SpanBuilder { SpanContext.create(traceId, spanId, traceOptions), spanOptions, name, + kind, parentSpanId, hasRemoteParent, activeTraceParams, @@ -196,6 +200,7 @@ final class SpanBuilderImpl extends SpanBuilder { sampler, parentLinks, recordEvents, + kind, timestampConverter); } @@ -234,4 +239,10 @@ final class SpanBuilderImpl extends SpanBuilder { this.recordEvents = recordEvents; return this; } + + @Override + public SpanBuilderImpl setSpanKind(Kind kind) { + this.kind = kind; + return this; + } } diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java index 59291685..75509a7f 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java @@ -66,6 +66,8 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { private final StartEndHandler startEndHandler; // The displayed name of the span. private final String name; + // The kind of the span. + @Nullable private final Kind kind; // The clock used to get the time. private final Clock clock; // The time converter used to convert nano time to Timestamp. This is needed because Java has @@ -132,6 +134,7 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { SpanContext context, @Nullable EnumSet<Options> options, String name, + @Nullable Kind kind, @Nullable SpanId parentSpanId, @Nullable Boolean hasRemoteParent, TraceParams traceParams, @@ -143,6 +146,7 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { context, options, name, + kind, parentSpanId, hasRemoteParent, traceParams, @@ -214,6 +218,16 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { } /** + * Returns the kind of this {@code Span}. + * + * @return the kind of this {@code Span}. + */ + @Nullable + public Kind getKind() { + return kind; + } + + /** * Returns the {@code TimestampConverter} used by this {@code Span}. * * @return the {@code TimestampConverter} used by this {@code Span}. @@ -253,6 +267,7 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { parentSpanId, hasRemoteParent, name, + kind, CheckerFrameworkUtils.castNonNull(timestampConverter).convertNanoTime(startNanoTime), attributesSpanData, annotationsSpanData, @@ -575,6 +590,7 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { SpanContext context, @Nullable EnumSet<Options> options, String name, + @Nullable Kind kind, @Nullable SpanId parentSpanId, @Nullable Boolean hasRemoteParent, TraceParams traceParams, @@ -585,6 +601,7 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { this.parentSpanId = parentSpanId; this.hasRemoteParent = hasRemoteParent; this.name = name; + this.kind = kind; this.traceParams = traceParams; this.startEndHandler = startEndHandler; this.clock = clock; |