Package zipkin2.proto3
Class Span
- All Implemented Interfaces:
Serializable
public final class Span extends com.squareup.wire.Message<Span,Span.Builder>
A span is a single-host view of an operation. A trace is a series of spans
(often RPC calls) which nest to form a latency tree. Spans are in the same
trace when they share the same trace ID. The parent_id field establishes the
position of one span in the tree.
The root span is where parent_id is Absent and usually has the longest
duration in the trace. However, nested asynchronous work can materialize as
child spans whose duration exceed the root span.
Spans usually represent remote activity such as RPC calls, or messaging
producers and consumers. However, they can also represent in-process
activity in any position of the trace. For example, a root span could
represent a server receiving an initial client request. A root span could
also represent a scheduled job that has no remote context.
Encoding notes:
Epoch timestamp are encoded fixed64 as varint would also be 8 bytes, and more
expensive to encode and size. Duration is stored uint64, as often the numbers
are quite small.
Default values are ok, as only natural numbers are used. For example, zero is
an invalid timestamp and an invalid duration, false values for debug or shared
are ignorable, and zero-length strings also coerce to null.
The next id is 14.
Note fields up to 15 take 1 byte to encode. Take care when adding new fields
https://developers.google.com/protocol-buffers/docs/proto3#assigning-tags
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSpan.Builderstatic classSpan.KindWhen present, kind clarifies timestamp, duration and remote_endpoint. -
Field Summary
Fields Modifier and Type Field Description static com.squareup.wire.ProtoAdapter<Span>ADAPTERList<Annotation>annotationsAssociates events that explain latency with the time they happened.BooleandebugTrue is a request to store this span even if it overrides sampling policy.static BooleanDEFAULT_DEBUGstatic LongDEFAULT_DURATIONstatic okio.ByteStringDEFAULT_IDstatic Span.KindDEFAULT_KINDstatic StringDEFAULT_NAMEstatic okio.ByteStringDEFAULT_PARENT_IDstatic BooleanDEFAULT_SHAREDstatic LongDEFAULT_TIMESTAMPstatic okio.ByteStringDEFAULT_TRACE_IDLongdurationDuration in microseconds of the critical path, if known.okio.ByteStringidUnique identifier for this operation within the trace.Span.KindkindWhen present, used to interpret remote_endpointEndpointlocal_endpointThe host that recorded this span, primarily for query by service name.StringnameThe logical operation this span represents in lowercase (e.g.okio.ByteStringparent_idThe parent span ID or absent if this the root span in a trace.Endpointremote_endpointWhen an RPC (or messaging) span, indicates the other side of the connection.BooleansharedTrue if we are contributing to a span started by another tracer (ex on a different host).Map<String,String>tagsTags give your span context for search, viewing and analysis.LongtimestampEpoch microseconds of the start of this span, possibly absent if incomplete.okio.ByteStringtrace_idRandomly generated, unique identifier for a trace, set on all spans within it. -
Constructor Summary
Constructors Constructor Description Span(okio.ByteString trace_id, okio.ByteString parent_id, okio.ByteString id, Span.Kind kind, String name, Long timestamp, Long duration, Endpoint local_endpoint, Endpoint remote_endpoint, List<Annotation> annotations, Map<String,String> tags, Boolean debug, Boolean shared)Span(okio.ByteString trace_id, okio.ByteString parent_id, okio.ByteString id, Span.Kind kind, String name, Long timestamp, Long duration, Endpoint local_endpoint, Endpoint remote_endpoint, List<Annotation> annotations, Map<String,String> tags, Boolean debug, Boolean shared, okio.ByteString unknownFields) -
Method Summary
Modifier and Type Method Description booleanequals(Object other)inthashCode()Span.BuildernewBuilder()StringtoString()
-
Field Details
-
ADAPTER
-
DEFAULT_TRACE_ID
public static final okio.ByteString DEFAULT_TRACE_ID -
DEFAULT_PARENT_ID
public static final okio.ByteString DEFAULT_PARENT_ID -
DEFAULT_ID
public static final okio.ByteString DEFAULT_ID -
DEFAULT_KIND
-
DEFAULT_NAME
- See Also:
- Constant Field Values
-
DEFAULT_TIMESTAMP
-
DEFAULT_DURATION
-
DEFAULT_DEBUG
-
DEFAULT_SHARED
-
trace_id
public final okio.ByteString trace_idRandomly generated, unique identifier for a trace, set on all spans within it. This field is required and encoded as 8 or 16 bytes, in big endian byte order. -
parent_id
public final okio.ByteString parent_idThe parent span ID or absent if this the root span in a trace. -
id
public final okio.ByteString idUnique identifier for this operation within the trace. This field is required and encoded as 8 opaque bytes. -
kind
When present, used to interpret remote_endpoint -
name
The logical operation this span represents in lowercase (e.g. rpc method). Leave absent if unknown. As these are lookup labels, take care to ensure names are low cardinality. For example, do not embed variables into the name. -
timestamp
Epoch microseconds of the start of this span, possibly absent if incomplete. For example, 1502787600000000 corresponds to 2017-08-15 09:00 UTC This value should be set directly by instrumentation, using the most precise value possible. For example, gettimeofday or multiplying epoch millis by 1000. There are three known edge-cases where this could be reported absent. - A span was allocated but never started (ex not yet received a timestamp) - The span's start event was lost - Data about a completed span (ex tags) were sent after the fact -
duration
Duration in microseconds of the critical path, if known. Durations of less than one are rounded up. Duration of children can be longer than their parents due to asynchronous operations. For example 150 milliseconds is 150000 microseconds. -
local_endpoint
The host that recorded this span, primarily for query by service name. Instrumentation should always record this. Usually, absent implies late data. The IP address corresponding to this is usually the site local or advertised service address. When present, the port indicates the listen port. -
remote_endpoint
When an RPC (or messaging) span, indicates the other side of the connection. By recording the remote endpoint, your trace will contain network context even if the peer is not tracing. For example, you can record the IP from the "X-Forwarded-For" header or the service name and socket of a remote peer. -
annotations
Associates events that explain latency with the time they happened. -
tags
Tags give your span context for search, viewing and analysis. For example, a key "your_app.version" would let you lookup traces by version. A tag "sql.query" isn't searchable, but it can help in debugging when viewing a trace. -
debug
True is a request to store this span even if it overrides sampling policy. This is true when the "X-B3-Flags" header has a value of 1. -
shared
True if we are contributing to a span started by another tracer (ex on a different host).
-
-
Constructor Details
-
Span
-
Span
public Span(okio.ByteString trace_id, okio.ByteString parent_id, okio.ByteString id, Span.Kind kind, String name, Long timestamp, Long duration, Endpoint local_endpoint, Endpoint remote_endpoint, List<Annotation> annotations, Map<String,String> tags, Boolean debug, Boolean shared, okio.ByteString unknownFields)
-
-
Method Details
-
newBuilder
- Specified by:
newBuilderin classcom.squareup.wire.Message<Span,Span.Builder>
-
equals
-
hashCode
public int hashCode() -
toString
- Overrides:
toStringin classcom.squareup.wire.Message<Span,Span.Builder>
-