Class TraceSpan.Builder (2.46.0)

public static final class TraceSpan.Builder extends GeneratedMessageV3.Builder<TraceSpan.Builder> implements TraceSpanOrBuilder

A span represents a single timed event within a trace. Spans can be nested and form a trace tree. Often, a trace contains a root span that describes the end-to-end latency of an operation and, optionally, one or more subspans for its suboperations. Spans do not need to be contiguous. There may be gaps between spans in a trace.

Protobuf type google.devtools.cloudtrace.v1.TraceSpan

Implements

TraceSpanOrBuilder

Static Methods

getDescriptor()

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

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public TraceSpan.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
TraceSpan.Builder
Overrides

build()

public TraceSpan build()
Returns
Type Description
TraceSpan

buildPartial()

public TraceSpan buildPartial()
Returns
Type Description
TraceSpan

clear()

public TraceSpan.Builder clear()
Returns
Type Description
TraceSpan.Builder
Overrides

clearEndTime()

public TraceSpan.Builder clearEndTime()

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Returns
Type Description
TraceSpan.Builder

clearField(Descriptors.FieldDescriptor field)

public TraceSpan.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
TraceSpan.Builder
Overrides

clearKind()

public TraceSpan.Builder clearKind()

Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using RPC_CLIENT and RPC_SERVER to identify queueing latency associated with the span.

.google.devtools.cloudtrace.v1.TraceSpan.SpanKind kind = 2;

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

clearLabels()

public TraceSpan.Builder clearLabels()
Returns
Type Description
TraceSpan.Builder

clearName()

public TraceSpan.Builder clearName()

Name of the span. Must be less than 128 bytes. The span name is sanitized and displayed in the Stackdriver Trace tool in the Google Cloud Platform Console. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans.

string name = 3;

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

public TraceSpan.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
TraceSpan.Builder
Overrides

clearParentSpanId()

public TraceSpan.Builder clearParentSpanId()

Optional. ID of the parent span, if any.

fixed64 parent_span_id = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

clearSpanId()

public TraceSpan.Builder clearSpanId()

Identifier for the span. Must be a 64-bit integer other than 0 and unique within a trace. For example, 2205310701640571284.

fixed64 span_id = 1;

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

clearStartTime()

public TraceSpan.Builder clearStartTime()

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Returns
Type Description
TraceSpan.Builder

clone()

public TraceSpan.Builder clone()
Returns
Type Description
TraceSpan.Builder
Overrides

containsLabels(String key)

public boolean containsLabels(String key)

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Parameter
Name Description
key String
Returns
Type Description
boolean

getDefaultInstanceForType()

public TraceSpan getDefaultInstanceForType()
Returns
Type Description
TraceSpan

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

getEndTime()

public Timestamp getEndTime()

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Returns
Type Description
Timestamp

The endTime.

getEndTimeBuilder()

public Timestamp.Builder getEndTimeBuilder()

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Returns
Type Description
Builder

getEndTimeOrBuilder()

public TimestampOrBuilder getEndTimeOrBuilder()

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Returns
Type Description
TimestampOrBuilder

getKind()

public TraceSpan.SpanKind getKind()

Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using RPC_CLIENT and RPC_SERVER to identify queueing latency associated with the span.

.google.devtools.cloudtrace.v1.TraceSpan.SpanKind kind = 2;

Returns
Type Description
TraceSpan.SpanKind

The kind.

getKindValue()

public int getKindValue()

Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using RPC_CLIENT and RPC_SERVER to identify queueing latency associated with the span.

.google.devtools.cloudtrace.v1.TraceSpan.SpanKind kind = 2;

Returns
Type Description
int

The enum numeric value on the wire for kind.

getLabels() (deprecated)

public Map<String,String> getLabels()

Use #getLabelsMap() instead.

Returns
Type Description
Map<String,String>

getLabelsCount()

public int getLabelsCount()

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Returns
Type Description
int

getLabelsMap()

public Map<String,String> getLabelsMap()

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Returns
Type Description
Map<String,String>

getLabelsOrDefault(String key, String defaultValue)

public String getLabelsOrDefault(String key, String defaultValue)

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Parameters
Name Description
key String
defaultValue String
Returns
Type Description
String

getLabelsOrThrow(String key)

public String getLabelsOrThrow(String key)

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Parameter
Name Description
key String
Returns
Type Description
String

getMutableLabels() (deprecated)

public Map<String,String> getMutableLabels()

Use alternate mutation accessors instead.

Returns
Type Description
Map<String,String>

getName()

public String getName()

Name of the span. Must be less than 128 bytes. The span name is sanitized and displayed in the Stackdriver Trace tool in the Google Cloud Platform Console. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans.

string name = 3;

Returns
Type Description
String

The name.

getNameBytes()

public ByteString getNameBytes()

Name of the span. Must be less than 128 bytes. The span name is sanitized and displayed in the Stackdriver Trace tool in the Google Cloud Platform Console. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans.

string name = 3;

Returns
Type Description
ByteString

The bytes for name.

getParentSpanId()

public long getParentSpanId()

Optional. ID of the parent span, if any.

fixed64 parent_span_id = 6 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
long

The parentSpanId.

getSpanId()

public long getSpanId()

Identifier for the span. Must be a 64-bit integer other than 0 and unique within a trace. For example, 2205310701640571284.

fixed64 span_id = 1;

Returns
Type Description
long

The spanId.

getStartTime()

public Timestamp getStartTime()

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Returns
Type Description
Timestamp

The startTime.

getStartTimeBuilder()

public Timestamp.Builder getStartTimeBuilder()

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Returns
Type Description
Builder

getStartTimeOrBuilder()

public TimestampOrBuilder getStartTimeOrBuilder()

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Returns
Type Description
TimestampOrBuilder

hasEndTime()

public boolean hasEndTime()

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Returns
Type Description
boolean

Whether the endTime field is set.

hasStartTime()

public boolean hasStartTime()

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Returns
Type Description
boolean

Whether the startTime field is set.

internalGetFieldAccessorTable()

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

internalGetMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMapFieldReflection(int number)
Parameter
Name Description
number int
Returns
Type Description
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMapFieldReflection(int)

internalGetMutableMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMutableMapFieldReflection(int number)
Parameter
Name Description
number int
Returns
Type Description
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMutableMapFieldReflection(int)

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeEndTime(Timestamp value)

public TraceSpan.Builder mergeEndTime(Timestamp value)

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Parameter
Name Description
value Timestamp
Returns
Type Description
TraceSpan.Builder

mergeFrom(TraceSpan other)

public TraceSpan.Builder mergeFrom(TraceSpan other)
Parameter
Name Description
other TraceSpan
Returns
Type Description
TraceSpan.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public TraceSpan.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
TraceSpan.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public TraceSpan.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
TraceSpan.Builder
Overrides

mergeStartTime(Timestamp value)

public TraceSpan.Builder mergeStartTime(Timestamp value)

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Parameter
Name Description
value Timestamp
Returns
Type Description
TraceSpan.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final TraceSpan.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
TraceSpan.Builder
Overrides

putAllLabels(Map<String,String> values)

public TraceSpan.Builder putAllLabels(Map<String,String> values)

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Parameter
Name Description
values Map<String,String>
Returns
Type Description
TraceSpan.Builder

putLabels(String key, String value)

public TraceSpan.Builder putLabels(String key, String value)

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Parameters
Name Description
key String
value String
Returns
Type Description
TraceSpan.Builder

removeLabels(String key)

public TraceSpan.Builder removeLabels(String key)

Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 kilobytes (10MB for /stacktrace values).

Some predefined label keys exist, or you may create your own. When creating your own, we recommend the following formats:

  • /category/product/key for agents of well-known products (e.g. /db/mongodb/read_size).
  • short_host/path/key for domain-specific keys (e.g. foo.com/myproduct/bar)

    Predefined labels include:

  • /agent

  • /component
  • /error/message
  • /error/name
  • /http/client_city
  • /http/client_country
  • /http/client_protocol
  • /http/client_region
  • /http/host
  • /http/method
  • /http/path
  • /http/redirected_url
  • /http/request/size
  • /http/response/size
  • /http/route
  • /http/status_code
  • /http/url
  • /http/user_agent
  • /pid
  • /stacktrace
  • /tid

map<string, string> labels = 7;

Parameter
Name Description
key String
Returns
Type Description
TraceSpan.Builder

setEndTime(Timestamp value)

public TraceSpan.Builder setEndTime(Timestamp value)

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Parameter
Name Description
value Timestamp
Returns
Type Description
TraceSpan.Builder

setEndTime(Timestamp.Builder builderForValue)

public TraceSpan.Builder setEndTime(Timestamp.Builder builderForValue)

End time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp end_time = 5;

Parameter
Name Description
builderForValue Builder
Returns
Type Description
TraceSpan.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public TraceSpan.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
TraceSpan.Builder
Overrides

setKind(TraceSpan.SpanKind value)

public TraceSpan.Builder setKind(TraceSpan.SpanKind value)

Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using RPC_CLIENT and RPC_SERVER to identify queueing latency associated with the span.

.google.devtools.cloudtrace.v1.TraceSpan.SpanKind kind = 2;

Parameter
Name Description
value TraceSpan.SpanKind

The kind to set.

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

setKindValue(int value)

public TraceSpan.Builder setKindValue(int value)

Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using RPC_CLIENT and RPC_SERVER to identify queueing latency associated with the span.

.google.devtools.cloudtrace.v1.TraceSpan.SpanKind kind = 2;

Parameter
Name Description
value int

The enum numeric value on the wire for kind to set.

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

setName(String value)

public TraceSpan.Builder setName(String value)

Name of the span. Must be less than 128 bytes. The span name is sanitized and displayed in the Stackdriver Trace tool in the Google Cloud Platform Console. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans.

string name = 3;

Parameter
Name Description
value String

The name to set.

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

setNameBytes(ByteString value)

public TraceSpan.Builder setNameBytes(ByteString value)

Name of the span. Must be less than 128 bytes. The span name is sanitized and displayed in the Stackdriver Trace tool in the Google Cloud Platform Console. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans.

string name = 3;

Parameter
Name Description
value ByteString

The bytes for name to set.

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

setParentSpanId(long value)

public TraceSpan.Builder setParentSpanId(long value)

Optional. ID of the parent span, if any.

fixed64 parent_span_id = 6 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value long

The parentSpanId to set.

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public TraceSpan.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
TraceSpan.Builder
Overrides

setSpanId(long value)

public TraceSpan.Builder setSpanId(long value)

Identifier for the span. Must be a 64-bit integer other than 0 and unique within a trace. For example, 2205310701640571284.

fixed64 span_id = 1;

Parameter
Name Description
value long

The spanId to set.

Returns
Type Description
TraceSpan.Builder

This builder for chaining.

setStartTime(Timestamp value)

public TraceSpan.Builder setStartTime(Timestamp value)

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Parameter
Name Description
value Timestamp
Returns
Type Description
TraceSpan.Builder

setStartTime(Timestamp.Builder builderForValue)

public TraceSpan.Builder setStartTime(Timestamp.Builder builderForValue)

Start time of the span in nanoseconds from the UNIX epoch.

.google.protobuf.Timestamp start_time = 4;

Parameter
Name Description
builderForValue Builder
Returns
Type Description
TraceSpan.Builder

setUnknownFields(UnknownFieldSet unknownFields)

public final TraceSpan.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
TraceSpan.Builder
Overrides