Class Span (2.48.0)

public final class Span extends GeneratedMessageV3 implements SpanOrBuilder

A span represents a single operation within a trace. Spans can be nested to form a trace tree. Often, a trace contains a root span that describes the end-to-end latency, and one or more subspans for its sub-operations.

A trace can also contain multiple root spans, or none at all. Spans do not need to be contiguous. There might be gaps or overlaps between spans in a trace.

Protobuf type google.devtools.cloudtrace.v2.Span

Implements

SpanOrBuilder

Static Fields

ATTRIBUTES_FIELD_NUMBER

public static final int ATTRIBUTES_FIELD_NUMBER
Field Value
Type Description
int

CHILD_SPAN_COUNT_FIELD_NUMBER

public static final int CHILD_SPAN_COUNT_FIELD_NUMBER
Field Value
Type Description
int

DISPLAY_NAME_FIELD_NUMBER

public static final int DISPLAY_NAME_FIELD_NUMBER
Field Value
Type Description
int

END_TIME_FIELD_NUMBER

public static final int END_TIME_FIELD_NUMBER
Field Value
Type Description
int
public static final int LINKS_FIELD_NUMBER
Field Value
Type Description
int

NAME_FIELD_NUMBER

public static final int NAME_FIELD_NUMBER
Field Value
Type Description
int

PARENT_SPAN_ID_FIELD_NUMBER

public static final int PARENT_SPAN_ID_FIELD_NUMBER
Field Value
Type Description
int

SAME_PROCESS_AS_PARENT_SPAN_FIELD_NUMBER

public static final int SAME_PROCESS_AS_PARENT_SPAN_FIELD_NUMBER
Field Value
Type Description
int

SPAN_ID_FIELD_NUMBER

public static final int SPAN_ID_FIELD_NUMBER
Field Value
Type Description
int

SPAN_KIND_FIELD_NUMBER

public static final int SPAN_KIND_FIELD_NUMBER
Field Value
Type Description
int

STACK_TRACE_FIELD_NUMBER

public static final int STACK_TRACE_FIELD_NUMBER
Field Value
Type Description
int

START_TIME_FIELD_NUMBER

public static final int START_TIME_FIELD_NUMBER
Field Value
Type Description
int

STATUS_FIELD_NUMBER

public static final int STATUS_FIELD_NUMBER
Field Value
Type Description
int

TIME_EVENTS_FIELD_NUMBER

public static final int TIME_EVENTS_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static Span getDefaultInstance()
Returns
Type Description
Span

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

newBuilder()

public static Span.Builder newBuilder()
Returns
Type Description
Span.Builder

newBuilder(Span prototype)

public static Span.Builder newBuilder(Span prototype)
Parameter
Name Description
prototype Span
Returns
Type Description
Span.Builder

parseDelimitedFrom(InputStream input)

public static Span parseDelimitedFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
Span
Exceptions
Type Description
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Span parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Span
Exceptions
Type Description
IOException

parseFrom(byte[] data)

public static Span parseFrom(byte[] data)
Parameter
Name Description
data byte[]
Returns
Type Description
Span
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static Span parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Span
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data)

public static Span parseFrom(ByteString data)
Parameter
Name Description
data ByteString
Returns
Type Description
Span
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static Span parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Span
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static Span parseFrom(CodedInputStream input)
Parameter
Name Description
input CodedInputStream
Returns
Type Description
Span
Exceptions
Type Description
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static Span parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Span
Exceptions
Type Description
IOException

parseFrom(InputStream input)

public static Span parseFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
Span
Exceptions
Type Description
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Span parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Span
Exceptions
Type Description
IOException

parseFrom(ByteBuffer data)

public static Span parseFrom(ByteBuffer data)
Parameter
Name Description
data ByteBuffer
Returns
Type Description
Span
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static Span parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteBuffer
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Span
Exceptions
Type Description
InvalidProtocolBufferException

parser()

public static Parser<Span> parser()
Returns
Type Description
Parser<Span>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
Name Description
obj Object
Returns
Type Description
boolean
Overrides

getAttributes()

public Span.Attributes getAttributes()

A set of attributes on the span. You can have up to 32 attributes per span.

.google.devtools.cloudtrace.v2.Span.Attributes attributes = 7;

Returns
Type Description
Span.Attributes

The attributes.

getAttributesOrBuilder()

public Span.AttributesOrBuilder getAttributesOrBuilder()

A set of attributes on the span. You can have up to 32 attributes per span.

.google.devtools.cloudtrace.v2.Span.Attributes attributes = 7;

Returns
Type Description
Span.AttributesOrBuilder

getChildSpanCount()

public Int32Value getChildSpanCount()

Optional. The number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans.

.google.protobuf.Int32Value child_span_count = 13 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Int32Value

The childSpanCount.

getChildSpanCountOrBuilder()

public Int32ValueOrBuilder getChildSpanCountOrBuilder()

Optional. The number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans.

.google.protobuf.Int32Value child_span_count = 13 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Int32ValueOrBuilder

getDefaultInstanceForType()

public Span getDefaultInstanceForType()
Returns
Type Description
Span

getDisplayName()

public TruncatableString getDisplayName()

Required. A description of the span's operation (up to 128 bytes). Cloud Trace displays the description in the Cloud console. For example, the display name can be a qualified method name or a file name and a line number where the operation is called. A best practice is to use the same display name within an application and at the same call point. This makes it easier to correlate spans in different traces.

.google.devtools.cloudtrace.v2.TruncatableString display_name = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
TruncatableString

The displayName.

getDisplayNameOrBuilder()

public TruncatableStringOrBuilder getDisplayNameOrBuilder()

Required. A description of the span's operation (up to 128 bytes). Cloud Trace displays the description in the Cloud console. For example, the display name can be a qualified method name or a file name and a line number where the operation is called. A best practice is to use the same display name within an application and at the same call point. This makes it easier to correlate spans in different traces.

.google.devtools.cloudtrace.v2.TruncatableString display_name = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
TruncatableStringOrBuilder

getEndTime()

public Timestamp getEndTime()

Required. The end time of the span. On the client side, this is the time kept by the local machine where the span execution ends. On the server side, this is the time when the server application handler stops running.

.google.protobuf.Timestamp end_time = 6 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Timestamp

The endTime.

getEndTimeOrBuilder()

public TimestampOrBuilder getEndTimeOrBuilder()

Required. The end time of the span. On the client side, this is the time kept by the local machine where the span execution ends. On the server side, this is the time when the server application handler stops running.

.google.protobuf.Timestamp end_time = 6 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
TimestampOrBuilder
public Span.Links getLinks()

Links associated with the span. You can have up to 128 links per Span.

.google.devtools.cloudtrace.v2.Span.Links links = 10;

Returns
Type Description
Span.Links

The links.

getLinksOrBuilder()

public Span.LinksOrBuilder getLinksOrBuilder()

Links associated with the span. You can have up to 128 links per Span.

.google.devtools.cloudtrace.v2.Span.Links links = 10;

Returns
Type Description
Span.LinksOrBuilder

getName()

public String getName()

Required. The resource name of the span in the following format:

  • projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]

    [TRACE_ID] is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. It should not be zero.

    [SPAN_ID] is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array. It should not be zero. .

string name = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
String

The name.

getNameBytes()

public ByteString getNameBytes()

Required. The resource name of the span in the following format:

  • projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]

    [TRACE_ID] is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. It should not be zero.

    [SPAN_ID] is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array. It should not be zero. .

string name = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
ByteString

The bytes for name.

getParentSpanId()

public String getParentSpanId()

The [SPAN_ID] of this span's parent span. If this is a root span, then this field must be empty.

string parent_span_id = 3;

Returns
Type Description
String

The parentSpanId.

getParentSpanIdBytes()

public ByteString getParentSpanIdBytes()

The [SPAN_ID] of this span's parent span. If this is a root span, then this field must be empty.

string parent_span_id = 3;

Returns
Type Description
ByteString

The bytes for parentSpanId.

getParserForType()

public Parser<Span> getParserForType()
Returns
Type Description
Parser<Span>
Overrides

getSameProcessAsParentSpan()

public BoolValue getSameProcessAsParentSpan()

Optional. Set this parameter to indicate whether this span is in the same process as its parent. If you do not set this parameter, Trace is unable to take advantage of this helpful information.

.google.protobuf.BoolValue same_process_as_parent_span = 12 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
BoolValue

The sameProcessAsParentSpan.

getSameProcessAsParentSpanOrBuilder()

public BoolValueOrBuilder getSameProcessAsParentSpanOrBuilder()

Optional. Set this parameter to indicate whether this span is in the same process as its parent. If you do not set this parameter, Trace is unable to take advantage of this helpful information.

.google.protobuf.BoolValue same_process_as_parent_span = 12 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
BoolValueOrBuilder

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
int
Overrides

getSpanId()

public String getSpanId()

Required. The [SPAN_ID] portion of the span's resource name.

string span_id = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
String

The spanId.

getSpanIdBytes()

public ByteString getSpanIdBytes()

Required. The [SPAN_ID] portion of the span's resource name.

string span_id = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
ByteString

The bytes for spanId.

getSpanKind()

public Span.SpanKind getSpanKind()

Optional. Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using CLIENT (caller) and SERVER (callee) to identify an RPC call.

.google.devtools.cloudtrace.v2.Span.SpanKind span_kind = 14 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Span.SpanKind

The spanKind.

getSpanKindValue()

public int getSpanKindValue()

Optional. Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using CLIENT (caller) and SERVER (callee) to identify an RPC call.

.google.devtools.cloudtrace.v2.Span.SpanKind span_kind = 14 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
int

The enum numeric value on the wire for spanKind.

getStackTrace()

public StackTrace getStackTrace()

Stack trace captured at the start of the span.

.google.devtools.cloudtrace.v2.StackTrace stack_trace = 8;

Returns
Type Description
StackTrace

The stackTrace.

getStackTraceOrBuilder()

public StackTraceOrBuilder getStackTraceOrBuilder()

Stack trace captured at the start of the span.

.google.devtools.cloudtrace.v2.StackTrace stack_trace = 8;

Returns
Type Description
StackTraceOrBuilder

getStartTime()

public Timestamp getStartTime()

Required. The start time of the span. On the client side, this is the time kept by the local machine where the span execution starts. On the server side, this is the time when the server's application handler starts running.

.google.protobuf.Timestamp start_time = 5 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
Timestamp

The startTime.

getStartTimeOrBuilder()

public TimestampOrBuilder getStartTimeOrBuilder()

Required. The start time of the span. On the client side, this is the time kept by the local machine where the span execution starts. On the server side, this is the time when the server's application handler starts running.

.google.protobuf.Timestamp start_time = 5 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
TimestampOrBuilder

getStatus()

public Status getStatus()

Optional. The final status for this span.

.google.rpc.Status status = 11 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
com.google.rpc.Status

The status.

getStatusOrBuilder()

public StatusOrBuilder getStatusOrBuilder()

Optional. The final status for this span.

.google.rpc.Status status = 11 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
com.google.rpc.StatusOrBuilder

getTimeEvents()

public Span.TimeEvents getTimeEvents()

A set of time events. You can have up to 32 annotations and 128 message events per span.

.google.devtools.cloudtrace.v2.Span.TimeEvents time_events = 9;

Returns
Type Description
Span.TimeEvents

The timeEvents.

getTimeEventsOrBuilder()

public Span.TimeEventsOrBuilder getTimeEventsOrBuilder()

A set of time events. You can have up to 32 annotations and 128 message events per span.

.google.devtools.cloudtrace.v2.Span.TimeEvents time_events = 9;

Returns
Type Description
Span.TimeEventsOrBuilder

hasAttributes()

public boolean hasAttributes()

A set of attributes on the span. You can have up to 32 attributes per span.

.google.devtools.cloudtrace.v2.Span.Attributes attributes = 7;

Returns
Type Description
boolean

Whether the attributes field is set.

hasChildSpanCount()

public boolean hasChildSpanCount()

Optional. The number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans.

.google.protobuf.Int32Value child_span_count = 13 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the childSpanCount field is set.

hasDisplayName()

public boolean hasDisplayName()

Required. A description of the span's operation (up to 128 bytes). Cloud Trace displays the description in the Cloud console. For example, the display name can be a qualified method name or a file name and a line number where the operation is called. A best practice is to use the same display name within an application and at the same call point. This makes it easier to correlate spans in different traces.

.google.devtools.cloudtrace.v2.TruncatableString display_name = 4 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the displayName field is set.

hasEndTime()

public boolean hasEndTime()

Required. The end time of the span. On the client side, this is the time kept by the local machine where the span execution ends. On the server side, this is the time when the server application handler stops running.

.google.protobuf.Timestamp end_time = 6 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the endTime field is set.

public boolean hasLinks()

Links associated with the span. You can have up to 128 links per Span.

.google.devtools.cloudtrace.v2.Span.Links links = 10;

Returns
Type Description
boolean

Whether the links field is set.

hasSameProcessAsParentSpan()

public boolean hasSameProcessAsParentSpan()

Optional. Set this parameter to indicate whether this span is in the same process as its parent. If you do not set this parameter, Trace is unable to take advantage of this helpful information.

.google.protobuf.BoolValue same_process_as_parent_span = 12 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the sameProcessAsParentSpan field is set.

hasStackTrace()

public boolean hasStackTrace()

Stack trace captured at the start of the span.

.google.devtools.cloudtrace.v2.StackTrace stack_trace = 8;

Returns
Type Description
boolean

Whether the stackTrace field is set.

hasStartTime()

public boolean hasStartTime()

Required. The start time of the span. On the client side, this is the time kept by the local machine where the span execution starts. On the server side, this is the time when the server's application handler starts running.

.google.protobuf.Timestamp start_time = 5 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the startTime field is set.

hasStatus()

public boolean hasStatus()

Optional. The final status for this span.

.google.rpc.Status status = 11 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the status field is set.

hasTimeEvents()

public boolean hasTimeEvents()

A set of time events. You can have up to 32 annotations and 128 message events per span.

.google.devtools.cloudtrace.v2.Span.TimeEvents time_events = 9;

Returns
Type Description
boolean

Whether the timeEvents field is set.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

newBuilderForType()

public Span.Builder newBuilderForType()
Returns
Type Description
Span.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected Span.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
Name Description
parent BuilderParent
Returns
Type Description
Span.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
Name Description
unused UnusedPrivateParameter
Returns
Type Description
Object
Overrides

toBuilder()

public Span.Builder toBuilder()
Returns
Type Description
Span.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException