@ThreadSafe public final class SpanImpl extends io.opencensus.trace.Span implements io.opencensus.trace.internal.ConcurrentIntrusiveList.Element<SpanImpl>
Span class.| Modifier and Type | Class and Description |
|---|---|
static interface |
SpanImpl.StartEndHandler
Interface to handle the start and end operations for a
Span only when the Span
has Options#RECORD_EVENTS option. |
| Modifier and Type | Method and Description |
|---|---|
void |
addAnnotation(io.opencensus.trace.Annotation annotation) |
void |
addAnnotation(String description,
Map<String,io.opencensus.trace.AttributeValue> attributes) |
void |
addAttributes(Map<String,io.opencensus.trace.AttributeValue> attributes) |
void |
addLink(io.opencensus.trace.Link link) |
void |
addNetworkEvent(io.opencensus.trace.NetworkEvent networkEvent) |
void |
end(io.opencensus.trace.EndSpanOptions options) |
long |
getEndNanoTime()
Returns the end nano time (see
System.nanoTime()). |
long |
getLatencyNs()
Returns the latency of the
Span in nanos. |
String |
getName()
Returns the name of the
Span. |
SpanImpl |
getNext() |
SpanImpl |
getPrev() |
io.opencensus.trace.Status |
getStatus()
Returns the status of the
Span. |
void |
setNext(SpanImpl element) |
void |
setPrev(SpanImpl element) |
static SpanImpl |
startSpan(io.opencensus.trace.SpanContext context,
EnumSet<io.opencensus.trace.Span.Options> options,
String name,
io.opencensus.trace.SpanId parentSpanId,
Boolean hasRemoteParent,
io.opencensus.trace.config.TraceParams traceParams,
SpanImpl.StartEndHandler startEndHandler,
io.opencensus.internal.TimestampConverter timestampConverter,
io.opencensus.common.Clock clock)
Creates and starts a span with the given configuration.
|
io.opencensus.trace.export.SpanData |
toSpanData()
Returns an immutable representation of all the data from this
Span. |
public static SpanImpl startSpan(io.opencensus.trace.SpanContext context, @Nullable EnumSet<io.opencensus.trace.Span.Options> options, String name, @Nullable io.opencensus.trace.SpanId parentSpanId, @Nullable Boolean hasRemoteParent, io.opencensus.trace.config.TraceParams traceParams, SpanImpl.StartEndHandler startEndHandler, @Nullable io.opencensus.internal.TimestampConverter timestampConverter, io.opencensus.common.Clock clock)
context - supplies the trace_id and span_id for the newly started span.options - the options for the new span, importantly Options.RECORD_EVENTS.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 - true if the parentContext is remote. null if 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.public String getName()
Span.Span.public io.opencensus.trace.Status getStatus()
Span. If not set defaults to Status.OK.Span.public long getEndNanoTime()
System.nanoTime()). If the current Span is not
ended then returns Clock.nowNanos().public long getLatencyNs()
Span in nanos. If still active then returns now() - start
time.Span in nanos.public io.opencensus.trace.export.SpanData toSpanData()
Span.Span.IllegalStateException - if the Span doesn't have RECORD_EVENTS option.public void addAttributes(Map<String,io.opencensus.trace.AttributeValue> attributes)
addAttributes in class io.opencensus.trace.Spanpublic void addAnnotation(String description, Map<String,io.opencensus.trace.AttributeValue> attributes)
addAnnotation in class io.opencensus.trace.Spanpublic void addAnnotation(io.opencensus.trace.Annotation annotation)
addAnnotation in class io.opencensus.trace.Spanpublic void addNetworkEvent(io.opencensus.trace.NetworkEvent networkEvent)
addNetworkEvent in class io.opencensus.trace.Spanpublic void addLink(io.opencensus.trace.Link link)
addLink in class io.opencensus.trace.Spanpublic void end(io.opencensus.trace.EndSpanOptions options)
end in class io.opencensus.trace.Spanpublic SpanImpl getNext()
getNext in interface io.opencensus.trace.internal.ConcurrentIntrusiveList.Element<SpanImpl>public void setNext(SpanImpl element)
setNext in interface io.opencensus.trace.internal.ConcurrentIntrusiveList.Element<SpanImpl>public SpanImpl getPrev()
getPrev in interface io.opencensus.trace.internal.ConcurrentIntrusiveList.Element<SpanImpl>