public final class TelemetrySpan
- Object
- TelemetrySpan
One timed operation in a distributed trace.
Network requests become spans by themselves once Telemetry is installed; an
app creates its own with Telemetry.startSpan(String) or
Telemetry.run(String, Runnable) to time something the user did – a tap, a
screen load – so the requests it caused are grouped under it.
A span the sampler declined is not recorded, but it still carries its trace context, and propagates the decision: the backend it calls agrees not to record either, so a trace is whole or absent rather than missing its middle.
Not thread safe. A span belongs to the thread doing the work it times, and is handed to the exporter only when it ends.
Fields
public static final int KIND_INTERNAL = 1 | An operation inside the app. |
public static final int KIND_CLIENT = 3 | A request the app makes to something else. |
Methods
Inherited methods
Field details
KIND_INTERNAL
public static final int KIND_INTERNAL = 1KIND_CLIENT
public static final int KIND_CLIENT = 3Method details
setAttribute
public TelemetrySpan setAttribute(String key, String value)Returns
setAttribute
public TelemetrySpan setAttribute(String key, long value)Returns
setAttribute
public TelemetrySpan setAttribute(String key, double value)Returns
setAttribute
public TelemetrySpan setAttribute(String key, boolean value)Returns
recordException
public TelemetrySpan recordException(Throwable error)Returns
setError
public TelemetrySpan setError(String description)Returns
updateName
public TelemetrySpan updateName(String newName)Returns
getName
public String getName()isRecording
public boolean isRecording()getTraceId
public String getTraceId()getSpanId
public String getSpanId()getTraceparent
public String getTraceparent()This span as a W3C traceparent header value, for a transport the
framework does not instrument itself – a WebSocket message, a push token
registration.
Null for the span Telemetry.startSpan(String) hands out when there is
no trace to join: telemetry is not installed, consent is required and not
given, or the platform cannot make ids. Its ids are all zeros, which W3C
Trace Context defines as invalid, so a header built from them would be
refused or misread downstream. An unsampled span is different: it is a real
trace whose decision must travel, and it answers with its -00 flags.
Returns
end
public void end()