public final class MockTracer.SpanBuilder extends Object implements Tracer.SpanBuilder
| Modifier and Type | Method and Description |
|---|---|
MockTracer.SpanBuilder |
addReference(String referenceType,
SpanContext referencedContext)
Add a reference from the Span being built to a distinct (usually parent) Span.
|
MockTracer.SpanBuilder |
asChildOf(BaseSpan parent)
A shorthand for addReference(References.CHILD_OF, parent.context()).
|
MockTracer.SpanBuilder |
asChildOf(SpanContext parent)
A shorthand for addReference(References.CHILD_OF, parent).
|
MockTracer.SpanBuilder |
ignoreActiveSpan()
Do not create an implicit
References.CHILD_OF reference to the ActiveSpanSource.activeSpan()). |
MockSpan |
start() |
ActiveSpan |
startActive()
Returns a newly started and activated
ActiveSpan. |
MockSpan |
startManual()
Like
Tracer.SpanBuilder.startActive(), but the returned Span has not been registered via the
ActiveSpanSource. |
MockTracer.SpanBuilder |
withStartTimestamp(long microseconds)
Specify a timestamp of when the Span was started, represented in microseconds since epoch.
|
MockTracer.SpanBuilder |
withTag(String key,
boolean value)
Same as
BaseSpan.setTag(String, boolean), but for the span being built. |
MockTracer.SpanBuilder |
withTag(String key,
Number value)
Same as
BaseSpan.setTag(String, Number), but for the span being built. |
MockTracer.SpanBuilder |
withTag(String key,
String value)
Same as
BaseSpan.setTag(String, String), but for the span being built. |
public MockTracer.SpanBuilder asChildOf(SpanContext parent)
Tracer.SpanBuilderIf parent==null, this is a noop.
asChildOf in interface Tracer.SpanBuilderpublic MockTracer.SpanBuilder asChildOf(BaseSpan parent)
Tracer.SpanBuilderIf parent==null, this is a noop.
asChildOf in interface Tracer.SpanBuilderpublic MockTracer.SpanBuilder ignoreActiveSpan()
Tracer.SpanBuilderReferences.CHILD_OF reference to the ActiveSpanSource.activeSpan()).ignoreActiveSpan in interface Tracer.SpanBuilderpublic MockTracer.SpanBuilder addReference(String referenceType, SpanContext referencedContext)
Tracer.SpanBuilderIf
Tracer's ActiveSpanSource.activeSpan() is not null, and
Tracer.SpanBuilder.addReference(java.lang.String, io.opentracing.v_030.SpanContext), and
Tracer.SpanBuilder.ignoreActiveSpan() is not invoked,
References.CHILD_OF reference is created to the
ActiveSpanSource.activeSpan() SpanContext when either Tracer.SpanBuilder.startActive() or
Tracer.SpanBuilder.startManual() is invoked.addReference in interface Tracer.SpanBuilderreferenceType - the reference type, typically one of the constants defined in ReferencesreferencedContext - the SpanContext being referenced; e.g., for a References.CHILD_OF referenceType, the
referencedContext is the parent. If referencedContext==null, the call to
Tracer.SpanBuilder.addReference(java.lang.String, io.opentracing.v_030.SpanContext) is a noop.Referencespublic MockTracer.SpanBuilder withTag(String key, String value)
Tracer.SpanBuilderBaseSpan.setTag(String, String), but for the span being built.withTag in interface Tracer.SpanBuilderpublic MockTracer.SpanBuilder withTag(String key, boolean value)
Tracer.SpanBuilderBaseSpan.setTag(String, boolean), but for the span being built.withTag in interface Tracer.SpanBuilderpublic MockTracer.SpanBuilder withTag(String key, Number value)
Tracer.SpanBuilderBaseSpan.setTag(String, Number), but for the span being built.withTag in interface Tracer.SpanBuilderpublic MockTracer.SpanBuilder withStartTimestamp(long microseconds)
Tracer.SpanBuilderwithStartTimestamp in interface Tracer.SpanBuilderpublic MockSpan start()
start in interface Tracer.SpanBuilderpublic ActiveSpan startActive()
Tracer.SpanBuilderActiveSpan.
The returned ActiveSpan supports try-with-resources. For example:
try (ActiveSpan span = tracer.buildSpan("...").startActive()) {
// (Do work)
span.setTag( ... ); // etc, etc
} // Span finishes automatically unless deferred via ActiveSpan.capture()
If
Tracer's ActiveSpanSource.activeSpan() is not null, and
Tracer.SpanBuilder.addReference(java.lang.String, io.opentracing.v_030.SpanContext), and
Tracer.SpanBuilder.ignoreActiveSpan() is not invoked,
References.CHILD_OF reference is created to the
ActiveSpanSource.activeSpan()'s SpanContext when either
Tracer.SpanBuilder.startManual() or Tracer.SpanBuilder.startActive() is invoked.
Note: Tracer.SpanBuilder.startActive() is a shorthand for
tracer.makeActive(spanBuilder.startManual()).
startActive in interface Tracer.SpanBuilderActiveSpan, already registered via the ActiveSpanSourceActiveSpanSource,
ActiveSpanpublic MockSpan startManual()
Tracer.SpanBuilderTracer.SpanBuilder.startActive(), but the returned Span has not been registered via the
ActiveSpanSource.startManual in interface Tracer.SpanBuilderActiveSpanSourceTracer.SpanBuilder.startActive()Copyright © 2016–2018 OpenTracing. All rights reserved.