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 TypeClassDescriptionstatic interfaceInterface to handle the start and end operations for aSpanonly when theSpanhasSpan.Options.RECORD_EVENTSoption.Nested classes/interfaces inherited from class Span
Span.Kind, Span.Options -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(Annotation annotation) Adds an annotation to theSpan.voidaddAnnotation(String description, Map<String, AttributeValue> attributes) Adds an annotation to theSpan.voidAdds aLinkto theSpan.voidaddMessageEvent(MessageEvent messageEvent) Adds a MessageEvent to theSpan.voidend(EndSpanOptions options) Marks the end ofSpanexecution with the given options.longReturns the end nano time (seeSystem.nanoTime()).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.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
-
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
-
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. -
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.
-