Class TraceSpan.Builder (2.41.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
TypeDescription
Descriptor

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public TraceSpan.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
NameDescription
fieldFieldDescriptor
valueObject
Returns
TypeDescription
TraceSpan.Builder
Overrides

build()

public TraceSpan build()
Returns
TypeDescription
TraceSpan

buildPartial()

public TraceSpan buildPartial()
Returns
TypeDescription
TraceSpan

clear()

public TraceSpan.Builder clear()
Returns
TypeDescription
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
TypeDescription
TraceSpan.Builder

clearField(Descriptors.FieldDescriptor field)

public TraceSpan.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
NameDescription
fieldFieldDescriptor
Returns
TypeDescription
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
TypeDescription
TraceSpan.Builder

This builder for chaining.

clearLabels()

public TraceSpan.Builder clearLabels()
Returns
TypeDescription
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
TypeDescription
TraceSpan.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

public TraceSpan.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
NameDescription
oneofOneofDescriptor
Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
TraceSpan.Builder

clone()

public TraceSpan.Builder clone()
Returns
TypeDescription
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
NameDescription
keyString
Returns
TypeDescription
boolean

getDefaultInstanceForType()

public TraceSpan getDefaultInstanceForType()
Returns
TypeDescription
TraceSpan

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
TypeDescription
Descriptor
Overrides

getEndTime()

public Timestamp getEndTime()

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

.google.protobuf.Timestamp end_time = 5;

Returns
TypeDescription
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
TypeDescription
Builder

getEndTimeOrBuilder()

public TimestampOrBuilder getEndTimeOrBuilder()

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

.google.protobuf.Timestamp end_time = 5;

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
int

The enum numeric value on the wire for kind.

getLabels() (deprecated)

public Map<String,String> getLabels()

Use #getLabelsMap() instead.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
keyString
defaultValueString
Returns
TypeDescription
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
NameDescription
keyString
Returns
TypeDescription
String

getMutableLabels() (deprecated)

public Map<String,String> getMutableLabels()

Use alternate mutation accessors instead.

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
Builder

getStartTimeOrBuilder()

public TimestampOrBuilder getStartTimeOrBuilder()

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

.google.protobuf.Timestamp start_time = 4;

Returns
TypeDescription
TimestampOrBuilder

hasEndTime()

public boolean hasEndTime()

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

.google.protobuf.Timestamp end_time = 5;

Returns
TypeDescription
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
TypeDescription
boolean

Whether the startTime field is set.

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

internalGetMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMapFieldReflection(int number)
Parameter
NameDescription
numberint
Returns
TypeDescription
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMapFieldReflection(int)

internalGetMutableMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMutableMapFieldReflection(int number)
Parameter
NameDescription
numberint
Returns
TypeDescription
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMutableMapFieldReflection(int)

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
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
NameDescription
valueTimestamp
Returns
TypeDescription
TraceSpan.Builder

mergeFrom(TraceSpan other)

public TraceSpan.Builder mergeFrom(TraceSpan other)
Parameter
NameDescription
otherTraceSpan
Returns
TypeDescription
TraceSpan.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public TraceSpan.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
TraceSpan.Builder
Overrides
Exceptions
TypeDescription
IOException

mergeFrom(Message other)

public TraceSpan.Builder mergeFrom(Message other)
Parameter
NameDescription
otherMessage
Returns
TypeDescription
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
NameDescription
valueTimestamp
Returns
TypeDescription
TraceSpan.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final TraceSpan.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
NameDescription
unknownFieldsUnknownFieldSet
Returns
TypeDescription
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
NameDescription
valuesMap<String,String>
Returns
TypeDescription
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
NameDescription
keyString
valueString
Returns
TypeDescription
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
NameDescription
keyString
Returns
TypeDescription
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
NameDescription
valueTimestamp
Returns
TypeDescription
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
NameDescription
builderForValueBuilder
Returns
TypeDescription
TraceSpan.Builder

setField(Descriptors.FieldDescriptor field, Object value)

public TraceSpan.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
NameDescription
fieldFieldDescriptor
valueObject
Returns
TypeDescription
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
NameDescription
valueTraceSpan.SpanKind

The kind to set.

Returns
TypeDescription
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
NameDescription
valueint

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

Returns
TypeDescription
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
NameDescription
valueString

The name to set.

Returns
TypeDescription
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
NameDescription
valueByteString

The bytes for name to set.

Returns
TypeDescription
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
NameDescription
valuelong

The parentSpanId to set.

Returns
TypeDescription
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
NameDescription
fieldFieldDescriptor
indexint
valueObject
Returns
TypeDescription
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
NameDescription
valuelong

The spanId to set.

Returns
TypeDescription
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
NameDescription
valueTimestamp
Returns
TypeDescription
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
NameDescription
builderForValueBuilder
Returns
TypeDescription
TraceSpan.Builder

setUnknownFields(UnknownFieldSet unknownFields)

public final TraceSpan.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
NameDescription
unknownFieldsUnknownFieldSet
Returns
TypeDescription
TraceSpan.Builder
Overrides