Package io.opencensus.trace
Class SpanBuilder.NoopSpanBuilder
- java.lang.Object
-
- io.opencensus.trace.SpanBuilder
-
- io.opencensus.trace.SpanBuilder.NoopSpanBuilder
-
- Enclosing class:
- SpanBuilder
static final class SpanBuilder.NoopSpanBuilder extends SpanBuilder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.opencensus.trace.SpanBuilder
SpanBuilder.NoopSpanBuilder
-
-
Constructor Summary
Constructors Modifier Constructor Description private
NoopSpanBuilder(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static SpanBuilder.NoopSpanBuilder
createWithParent(java.lang.String spanName, Span parent)
(package private) static SpanBuilder.NoopSpanBuilder
createWithRemoteParent(java.lang.String spanName, SpanContext remoteParentSpanContext)
SpanBuilder
setParentLinks(java.util.List<Span> parentLinks)
Sets theList
of parent links.SpanBuilder
setRecordEvents(boolean recordEvents)
Sets the optionSpan.Options.RECORD_EVENTS
for the newly createdSpan
.SpanBuilder
setSampler(Sampler sampler)
Sets theSampler
to use.SpanBuilder
setSpanKind(Span.Kind spanKind)
Sets theSpan.Kind
for the newly createdSpan
.Span
startSpan()
Starts a newSpan
.-
Methods inherited from class io.opencensus.trace.SpanBuilder
startScopedSpan, startSpanAndCall, startSpanAndRun
-
-
-
-
Method Detail
-
createWithParent
static SpanBuilder.NoopSpanBuilder createWithParent(java.lang.String spanName, @Nullable Span parent)
-
createWithRemoteParent
static SpanBuilder.NoopSpanBuilder createWithRemoteParent(java.lang.String spanName, @Nullable SpanContext remoteParentSpanContext)
-
startSpan
public Span startSpan()
Description copied from class:SpanBuilder
Starts a newSpan
.Users must manually call
Span.end()
orSpan.end(EndSpanOptions)
to end thisSpan
.Does not install the newly created
Span
to the current Context.Example of usage:
class MyClass { private static final Tracer tracer = Tracing.getTracer(); void DoWork(Span parent) { Span childSpan = tracer.spanBuilderWithExplicitParent("MyChildSpan", parent).startSpan(); childSpan.addAnnotation("my annotation"); try { doSomeWork(childSpan); // Manually propagate the new span down the stack. } finally { // To make sure we end the span even in case of an exception. childSpan.end(); // Manually end the span. } } }
- Specified by:
startSpan
in classSpanBuilder
- Returns:
- the newly created
Span
.
-
setSampler
public SpanBuilder setSampler(@Nullable Sampler sampler)
Description copied from class:SpanBuilder
Sets theSampler
to use. If not set, the implementation will provide a default.- Specified by:
setSampler
in classSpanBuilder
- Parameters:
sampler
- theSampler
to use when determining sampling for aSpan
.- Returns:
- this.
-
setParentLinks
public SpanBuilder setParentLinks(java.util.List<Span> parentLinks)
Description copied from class:SpanBuilder
Sets theList
of parent links. Links are used to linkSpan
s in different traces. Used (for example) in batching operations, where a single batch handler processes multiple requests from different traces.- Specified by:
setParentLinks
in classSpanBuilder
- Parameters:
parentLinks
- new links to be added.- Returns:
- this.
-
setRecordEvents
public SpanBuilder setRecordEvents(boolean recordEvents)
Description copied from class:SpanBuilder
Sets the optionSpan.Options.RECORD_EVENTS
for the newly createdSpan
. If not called, the implementation will provide a default.- Specified by:
setRecordEvents
in classSpanBuilder
- Parameters:
recordEvents
- new value determining if thisSpan
should have events recorded.- Returns:
- this.
-
setSpanKind
public SpanBuilder setSpanKind(@Nullable Span.Kind spanKind)
Description copied from class:SpanBuilder
Sets theSpan.Kind
for the newly createdSpan
. If not called, the implementation will provide a default.- Overrides:
setSpanKind
in classSpanBuilder
- Parameters:
spanKind
- the kind of the newly createdSpan
.- Returns:
- this.
-
-