Class Span
java.lang.Object
com.codename1.backend.Span
One timed operation inside a distributed trace.
The server creates these itself -- one per request, one per outbound
Web call and one per Database statement -- so an application
normally only touches the current one, through Tracing.current(), to
add an attribute. Tracing.inSpan(String, Tracing.Work) wraps a block of its own work.
When tracing is not installed every method here is a no-op on a shared instance, so code that decorates the current span costs nothing in a server that does not export traces.
The kinds and status codes are the numbers the OTLP wire format uses, so a tracer can write them without translating.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA request this process makes to something else.static final intAn operation inside the process.static final intAnswering a request that arrived from outside. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddiscard()Drops the span: it ends normally but is never exported.abstract voidend()Ends the span.abstract intgetKind()One of the KIND constants.abstract StringgetName()The current name.abstract booleanWhether this span is being recorded.abstract SpanrecordException(Throwable error) Records a failure as an "exception" event and marks the span as an error.abstract SpansetAttribute(String key, boolean value) Adds or replaces a flag attribute.abstract SpansetAttribute(String key, double value) Adds or replaces a floating point attribute.abstract SpansetAttribute(String key, long value) Adds or replaces an integer attribute.abstract SpansetAttribute(String key, String value) Adds or replaces a string attribute.abstract SpanMarks the span as failed, with a short description.abstract StringThis span as a W3Ctraceparentvalue, which is what an outbound request carries so the service it reaches joins the same trace.abstract StringThe W3Ctracestatethis trace carries, or null for none.abstract SpanupdateName(String name) Renames the span.
-
Field Details
-
KIND_INTERNAL
public static final int KIND_INTERNALAn operation inside the process.- See Also:
-
KIND_SERVER
public static final int KIND_SERVERAnswering a request that arrived from outside.- See Also:
-
KIND_CLIENT
public static final int KIND_CLIENTA request this process makes to something else.- See Also:
-
-
Constructor Details
-
Span
protected Span()For tracer implementations.
-
-
Method Details
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
recordException
-
setError
-
updateName
-
getName
The current name. -
getKind
public abstract int getKind()One of the KIND constants. -
isRecording
public abstract boolean isRecording()Whether this span is being recorded. A span the sampler declined still carries a trace context and propagates it, so the NEXT service agrees not to record either -- but attributes set on it go nowhere, and a caller that would compute an expensive one can ask first. -
traceparent
This span as a W3Ctraceparentvalue, which is what an outbound request carries so the service it reaches joins the same trace. Null for the no-op span. -
tracestate
The W3Ctracestatethis trace carries, or null for none. -
discard
public abstract void discard()Drops the span: it ends normally but is never exported. For traffic that is about tracing itself, which would otherwise report on every export. -
end
public abstract void end()Ends the span. Only the first call counts.
-