Class RecordEventsSpanImpl
java.lang.Object
io.opencensus.trace.Span
io.opencensus.implcore.trace.RecordEventsSpanImpl
- All Implemented Interfaces:
ConcurrentIntrusiveList.Element<RecordEventsSpanImpl>
@ThreadSafe
public final class RecordEventsSpanImpl
extends Span
implements ConcurrentIntrusiveList.Element<RecordEventsSpanImpl>
Implementation for the
Span class that records trace events.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static final classstatic interfaceInterface to handle the start and end operations for aSpanonly when theSpanhasSpan.Options.RECORD_EVENTSoption.private static final classNested classes/interfaces inherited from class Span
Span.Kind, Span.Options -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Clockprivate longprivate booleanprivate final Booleanprivate final Span.Kindprivate RecordEventsSpanImpl.TraceEvents<Link> private static final Loggerprivate final Stringprivate RecordEventsSpanImplprivate intprivate final SpanIdprivate RecordEventsSpanImplprivate static final EnumSet<Span.Options> private booleanprivate final RecordEventsSpanImpl.StartEndHandlerprivate final longprivate Statusprivate final TimestampConverterprivate final TraceParams -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateRecordEventsSpanImpl(SpanContext context, String name, Span.Kind kind, SpanId parentSpanId, Boolean hasRemoteParent, TraceParams traceParams, RecordEventsSpanImpl.StartEndHandler startEndHandler, TimestampConverter timestampConverter, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(Annotation annotation) Adds an annotation to theSpan.voidaddAnnotation(String description, Map<String, AttributeValue> attributes) Adds an annotation to theSpan.(package private) voidaddChild()voidAdds aLinkto theSpan.voidaddMessageEvent(MessageEvent messageEvent) Adds a MessageEvent to theSpan.private static <T> SpanData.TimedEvents<T> createTimedEvents(RecordEventsSpanImpl.TraceEvents<RecordEventsSpanImpl.EventWithNanoTime<T>> events, TimestampConverter timestampConverter) voidend(EndSpanOptions options) Marks the end ofSpanexecution with the given options.longReturns the end nano time (seeSystem.nanoTime()).private RecordEventsSpanImpl.TraceEvents<Link> getKind()Returns the kind of thisSpan.longReturns the latency of theSpanin nanos.getName()Returns the name of theSpan.getNext()Returns a reference to the next element in the list.getPrev()Returns a reference to the previous element in the list.booleanReturns if the name of thisSpanmust be register to theSampledSpanStore.Returns the status of theSpan.private Status(package private) TimestampConverterReturns theTimestampConverterused by thisSpan.voidputAttribute(String key, AttributeValue value) Sets an attribute to theSpan.voidputAttributes(Map<String, AttributeValue> attributes) Sets a set of attributes to theSpan.voidsetNext(RecordEventsSpanImpl element) Sets the reference to the next element in the list.voidsetPrev(RecordEventsSpanImpl element) Sets the reference to the previous element in the list.voidSets theStatusto theSpan.static RecordEventsSpanImplstartSpan(SpanContext context, String name, Span.Kind kind, SpanId parentSpanId, Boolean hasRemoteParent, TraceParams traceParams, RecordEventsSpanImpl.StartEndHandler startEndHandler, TimestampConverter timestampConverter, Clock clock) Creates and starts a span with the given configuration.Returns an immutable representation of all the data from thisSpan.Methods inherited from class Span
addAnnotation, addAttributes, addNetworkEvent, end, getContext, getOptions
-
Field Details
-
logger
-
RECORD_EVENTS_SPAN_OPTIONS
-
parentSpanId
-
hasRemoteParent
-
traceParams
-
startEndHandler
-
name
-
kind
-
clock
-
timestampConverter
-
startNanoTime
private final long startNanoTime -
attributes
-
annotations
@Nullable private RecordEventsSpanImpl.TraceEvents<RecordEventsSpanImpl.EventWithNanoTime<Annotation>> annotations -
messageEvents
@Nullable private RecordEventsSpanImpl.TraceEvents<RecordEventsSpanImpl.EventWithNanoTime<MessageEvent>> messageEvents -
links
-
numberOfChildren
private int numberOfChildren -
status
-
endNanoTime
private long endNanoTime -
hasBeenEnded
private boolean hasBeenEnded -
sampleToLocalSpanStore
private boolean sampleToLocalSpanStore -
next
-
prev
-
-
Constructor Details
-
RecordEventsSpanImpl
private RecordEventsSpanImpl(SpanContext context, String name, @Nullable Span.Kind kind, @Nullable SpanId parentSpanId, @Nullable Boolean hasRemoteParent, TraceParams traceParams, RecordEventsSpanImpl.StartEndHandler startEndHandler, @Nullable TimestampConverter timestampConverter, Clock clock)
-
-
Method Details
-
startSpan
public static RecordEventsSpanImpl startSpan(SpanContext context, String name, @Nullable Span.Kind kind, @Nullable SpanId parentSpanId, @Nullable Boolean hasRemoteParent, TraceParams traceParams, RecordEventsSpanImpl.StartEndHandler startEndHandler, @Nullable TimestampConverter timestampConverter, Clock clock) Creates and starts a span with the given configuration.- Parameters:
context- supplies the trace_id and span_id for the newly started span.name- the displayed name for the new span.parentSpanId- the span_id of the parent span, or null if the new span is a root span.hasRemoteParent-trueif the parentContext is remote.nullif this is a root span.traceParams- trace parameters like sampler and probability.startEndHandler- handler called when the span starts and ends.timestampConverter- null if the span is a root span or the parent is not sampled. If the parent is sampled, we should use the same converter to ensure ordering between tracing events.clock- the clock used to get the time.- Returns:
- a new and started span.
-
getName
-
getStatus
-
getEndNanoTime
public long getEndNanoTime()Returns the end nano time (seeSystem.nanoTime()). If the currentSpanis not ended then returnsClock.nowNanos().- Returns:
- the end nano time.
-
getLatencyNs
public long getLatencyNs()Returns the latency of theSpanin nanos. If still active then returns now() - start time.- Returns:
- the latency of the
Spanin nanos.
-
getSampleToLocalSpanStore
public boolean getSampleToLocalSpanStore()Returns if the name of thisSpanmust be register to theSampledSpanStore.- Returns:
- if the name of this
Spanmust be register to theSampledSpanStore.
-
getKind
-
getTimestampConverter
Returns theTimestampConverterused by thisSpan.- Returns:
- the
TimestampConverterused by thisSpan.
-
toSpanData
Returns an immutable representation of all the data from thisSpan.- Returns:
- an immutable representation of all the data from this
Span. - Throws:
IllegalStateException- if the Span doesn't have RECORD_EVENTS option.
-
putAttribute
Description copied from class:SpanSets an attribute to theSpan. If theSpanpreviously contained a mapping for the key, the old value is replaced by the specified value.- Overrides:
putAttributein classSpan- Parameters:
key- the key for this attribute.value- the value for this attribute.
-
putAttributes
Description copied from class:SpanSets a set of attributes to theSpan. The effect of this call is equivalent to that of callingSpan.putAttribute(String, AttributeValue)once for each element in the specified map.- Overrides:
putAttributesin classSpan- Parameters:
attributes- the attributes that will be added and associated with theSpan.
-
addAnnotation
Description copied from class:SpanAdds an annotation to theSpan.- Specified by:
addAnnotationin classSpan- Parameters:
description- the description of the annotation time event.attributes- the attributes that will be added; these are associated with this annotation, not theSpanas forSpan.putAttributes(Map).
-
addAnnotation
Description copied from class:SpanAdds an annotation to theSpan.- Specified by:
addAnnotationin classSpan- Parameters:
annotation- the annotations to add.
-
addMessageEvent
Description copied from class:SpanAdds a MessageEvent to theSpan.This function can be used by higher level applications to record messaging event.
This method should always be overridden by users whose API versions are larger or equal to
0.12.- Overrides:
addMessageEventin classSpan- Parameters:
messageEvent- the message to add.
-
addLink
-
setStatus
Description copied from class:SpanSets theStatusto theSpan.If used, this will override the default
Spanstatus. Default isStatus.OK.Only the value of the last call will be recorded, and implementations are free to ignore previous calls. If the status is set via
EndSpanOptions.Builder.setStatus(Status)that will always be the last call. -
end
Description copied from class:SpanMarks the end ofSpanexecution with the given options.Only the timing of the first end call for a given
Spanwill be recorded, and implementations are free to ignore all further calls. -
addChild
void addChild() -
getInitializedAttributes
-
getInitializedAnnotations
private RecordEventsSpanImpl.TraceEvents<RecordEventsSpanImpl.EventWithNanoTime<Annotation>> getInitializedAnnotations() -
getInitializedNetworkEvents
private RecordEventsSpanImpl.TraceEvents<RecordEventsSpanImpl.EventWithNanoTime<MessageEvent>> getInitializedNetworkEvents() -
getInitializedLinks
-
getStatusWithDefault
-
createTimedEvents
private static <T> SpanData.TimedEvents<T> createTimedEvents(RecordEventsSpanImpl.TraceEvents<RecordEventsSpanImpl.EventWithNanoTime<T>> events, TimestampConverter timestampConverter) -
getNext
Description copied from interface:ConcurrentIntrusiveList.ElementReturns a reference to the next element in the list.- Specified by:
getNextin interfaceConcurrentIntrusiveList.Element<RecordEventsSpanImpl>- Returns:
- a reference to the next element in the list.
-
setNext
Description copied from interface:ConcurrentIntrusiveList.ElementSets the reference to the next element in the list.- Specified by:
setNextin interfaceConcurrentIntrusiveList.Element<RecordEventsSpanImpl>- Parameters:
element- the reference to the next element in the list.
-
getPrev
Description copied from interface:ConcurrentIntrusiveList.ElementReturns a reference to the previous element in the list.- Specified by:
getPrevin interfaceConcurrentIntrusiveList.Element<RecordEventsSpanImpl>- Returns:
- a reference to the previous element in the list.
-
setPrev
Description copied from interface:ConcurrentIntrusiveList.ElementSets the reference to the previous element in the list.- Specified by:
setPrevin interfaceConcurrentIntrusiveList.Element<RecordEventsSpanImpl>- Parameters:
element- the reference to the previous element in the list.
-