Class SpanBuilderImpl
java.lang.Object
io.opencensus.trace.SpanBuilder
io.opencensus.implcore.trace.SpanBuilderImpl
Implementation of the
SpanBuilder.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Span.Kindprivate final Stringprivate static final TraceOptionsprivate final SpanBuilderImpl.Optionsprivate final Spanprivate Booleanprivate final SpanContextprivate static final TraceOptionsprivate Samplerprivate static final Tracestate -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSpanBuilderImpl(String name, SpanContext remoteParentSpanContext, Span parent, SpanBuilderImpl.Options options) -
Method Summary
Modifier and TypeMethodDescription(package private) static SpanBuilderImplcreateWithParent(String spanName, Span parent, SpanBuilderImpl.Options options) (package private) static SpanBuilderImplcreateWithRemoteParent(String spanName, SpanContext remoteParentSpanContext, SpanBuilderImpl.Options options) private static booleanisAnyParentLinkSampled(List<Span> parentLinks) private static voidprivate static booleanmakeSamplingDecision(SpanContext parent, Boolean hasRemoteParent, String name, Sampler sampler, List<Span> parentLinks, TraceId traceId, SpanId spanId, TraceParams activeTraceParams) setParentLinks(List<Span> parentLinks) Sets theListof parent links.setRecordEvents(boolean recordEvents) Sets the optionSpan.Options.RECORD_EVENTSfor the newly createdSpan.setSampler(Sampler sampler) Sets theSamplerto use.setSpanKind(Span.Kind kind) Sets theSpan.Kindfor the newly createdSpan.Starts a newSpan.private SpanstartSpanInternal(SpanContext parentContext, Boolean hasRemoteParent, String name, Sampler sampler, List<Span> parentLinks, Boolean recordEvents, Span.Kind kind, Span parentSpan) Methods inherited from class SpanBuilder
startScopedSpan, startSpanAndCall, startSpanAndRun
-
Field Details
-
TRACESTATE_DEFAULT
-
SAMPLED_TRACE_OPTIONS
-
NOT_SAMPLED_TRACE_OPTIONS
-
options
-
name
-
parent
-
remoteParentSpanContext
-
sampler
-
parentLinks
-
recordEvents
-
kind
-
-
Constructor Details
-
SpanBuilderImpl
private SpanBuilderImpl(String name, @Nullable SpanContext remoteParentSpanContext, @Nullable Span parent, SpanBuilderImpl.Options options)
-
-
Method Details
-
startSpanInternal
-
makeSamplingDecision
-
isAnyParentLinkSampled
-
linkSpans
-
createWithParent
static SpanBuilderImpl createWithParent(String spanName, @Nullable Span parent, SpanBuilderImpl.Options options) -
createWithRemoteParent
static SpanBuilderImpl createWithRemoteParent(String spanName, @Nullable SpanContext remoteParentSpanContext, SpanBuilderImpl.Options options) -
startSpan
Description copied from class:SpanBuilderStarts a newSpan.Users must manually call
Span.end()orSpan.end(EndSpanOptions)to end thisSpan.Does not install the newly created
Spanto 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:
startSpanin classSpanBuilder- Returns:
- the newly created
Span.
-
setSampler
Description copied from class:SpanBuilderSets theSamplerto use. If not set, the implementation will provide a default.- Specified by:
setSamplerin classSpanBuilder- Parameters:
sampler- theSamplerto use when determining sampling for aSpan.- Returns:
- this.
-
setParentLinks
Description copied from class:SpanBuilderSets theListof parent links. Links are used to linkSpans in different traces. Used (for example) in batching operations, where a single batch handler processes multiple requests from different traces.- Specified by:
setParentLinksin classSpanBuilder- Parameters:
parentLinks- new links to be added.- Returns:
- this.
-
setRecordEvents
Description copied from class:SpanBuilderSets the optionSpan.Options.RECORD_EVENTSfor the newly createdSpan. If not called, the implementation will provide a default.- Specified by:
setRecordEventsin classSpanBuilder- Parameters:
recordEvents- new value determining if thisSpanshould have events recorded.- Returns:
- this.
-
setSpanKind
Description copied from class:SpanBuilderSets theSpan.Kindfor the newly createdSpan. If not called, the implementation will provide a default.- Overrides:
setSpanKindin classSpanBuilder- Parameters:
kind- the kind of the newly createdSpan.- Returns:
- this.
-