Stackdriver Trace V2 Client - Class Span (1.4.11)

Reference documentation and code samples for the Stackdriver Trace V2 Client class Span.

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 may be gaps or overlaps between spans in a trace.

Generated from protobuf message google.devtools.cloudtrace.v2.Span

Methods

__construct

Constructor.

Parameters
Name
Description
data
array

Optional. Data for populating the Message object.

↳ name
string

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. [SPAN_ID] is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array.

↳ span_id
string

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

↳ parent_span_id
string

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

↳ display_name
Google\Cloud\Trace\V2\TruncatableString

Required. A description of the span's operation (up to 128 bytes). Stackdriver Trace displays the description in the Google Cloud Platform 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.

↳ start_time
Google\Protobuf\Timestamp

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.

↳ end_time
Google\Protobuf\Timestamp

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.

↳ attributes
Google\Cloud\Trace\V2\Span\Attributes

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

↳ stack_trace
Google\Cloud\Trace\V2\StackTrace

Stack trace captured at the start of the span.

↳ time_events
Google\Cloud\Trace\V2\Span\TimeEvents

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

↳ links
Google\Cloud\Trace\V2\Span\Links

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

↳ status
Google\Rpc\Status

Optional. The final status for this span.

↳ same_process_as_parent_span
Google\Protobuf\BoolValue

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

↳ child_span_count
Google\Protobuf\Int32Value

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

↳ span_kind
int

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.

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.

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

Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED];

Returns
Type
Description
string

setName

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.

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

Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED];

Parameter
Name
Description
var
string
Returns
Type
Description
$this

getSpanId

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

Generated from protobuf field string span_id = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type
Description
string

setSpanId

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

Generated from protobuf field string span_id = 2 [(.google.api.field_behavior) = REQUIRED];

Parameter
Name
Description
var
string
Returns
Type
Description
$this

getParentSpanId

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

Generated from protobuf field string parent_span_id = 3;

Returns
Type
Description
string

setParentSpanId

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

Generated from protobuf field string parent_span_id = 3;

Parameter
Name
Description
var
string
Returns
Type
Description
$this

getDisplayName

Required. A description of the span's operation (up to 128 bytes).

Stackdriver Trace displays the description in the Google Cloud Platform 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.

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

Returns
Type
Description

hasDisplayName

clearDisplayName

setDisplayName

Required. A description of the span's operation (up to 128 bytes).

Stackdriver Trace displays the description in the Google Cloud Platform 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.

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

Parameter
Name
Description
Returns
Type
Description
$this

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.

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

Returns
Type
Description
Google\Protobuf\Timestamp|null

hasStartTime

clearStartTime

setStartTime

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.

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

Parameter
Name
Description
var
Google\Protobuf\Timestamp
Returns
Type
Description
$this

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.

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

Returns
Type
Description
Google\Protobuf\Timestamp|null

hasEndTime

clearEndTime

setEndTime

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.

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

Parameter
Name
Description
var
Google\Protobuf\Timestamp
Returns
Type
Description
$this

getAttributes

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

Generated from protobuf field .google.devtools.cloudtrace.v2.Span.Attributes attributes = 7;

Returns
Type
Description

hasAttributes

clearAttributes

setAttributes

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

Generated from protobuf field .google.devtools.cloudtrace.v2.Span.Attributes attributes = 7;

Parameter
Name
Description
Returns
Type
Description
$this

getStackTrace

Stack trace captured at the start of the span.

Generated from protobuf field .google.devtools.cloudtrace.v2.StackTrace stack_trace = 8;

Returns
Type
Description

hasStackTrace

clearStackTrace

setStackTrace

Stack trace captured at the start of the span.

Generated from protobuf field .google.devtools.cloudtrace.v2.StackTrace stack_trace = 8;

Parameter
Name
Description
Returns
Type
Description
$this

getTimeEvents

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

Generated from protobuf field .google.devtools.cloudtrace.v2.Span.TimeEvents time_events = 9;

Returns
Type
Description

hasTimeEvents

clearTimeEvents

setTimeEvents

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

Generated from protobuf field .google.devtools.cloudtrace.v2.Span.TimeEvents time_events = 9;

Parameter
Name
Description
Returns
Type
Description
$this

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

Generated from protobuf field .google.devtools.cloudtrace.v2.Span.Links links = 10;

Returns
Type
Description

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

Generated from protobuf field .google.devtools.cloudtrace.v2.Span.Links links = 10;

Parameter
Name
Description
Returns
Type
Description
$this

getStatus

Optional. The final status for this span.

Generated from protobuf field .google.rpc.Status status = 11 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type
Description

hasStatus

clearStatus

setStatus

Optional. The final status for this span.

Generated from protobuf field .google.rpc.Status status = 11 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name
Description
Returns
Type
Description
$this

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, Stackdriver Trace is unable to take advantage of this helpful information.

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

Returns
Type
Description
Google\Protobuf\BoolValue|null

hasSameProcessAsParentSpan

clearSameProcessAsParentSpan

getSameProcessAsParentSpanValue

Returns the unboxed value from 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, Stackdriver Trace is unable to take advantage of this helpful information.

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

Returns
Type
Description
bool|null

setSameProcessAsParentSpan

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

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

Parameter
Name
Description
var
Google\Protobuf\BoolValue
Returns
Type
Description
$this

setSameProcessAsParentSpanValue

Sets the field by wrapping a primitive type in a Google\Protobuf\BoolValue object.

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

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

Parameter
Name
Description
var
bool|null
Returns
Type
Description
$this

getChildSpanCount

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

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

Returns
Type
Description
Google\Protobuf\Int32Value|null

hasChildSpanCount

clearChildSpanCount

getChildSpanCountValue

Returns the unboxed value from getChildSpanCount()

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

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

Returns
Type
Description
int|null

setChildSpanCount

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

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

Parameter
Name
Description
var
Google\Protobuf\Int32Value
Returns
Type
Description
$this

setChildSpanCountValue

Sets the field by wrapping a primitive type in a Google\Protobuf\Int32Value object.

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

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

Parameter
Name
Description
var
int|null
Returns
Type
Description
$this

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.

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

Returns
Type
Description
int

setSpanKind

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.

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

Parameter
Name
Description
var
int
Returns
Type
Description
$this
Create a Mobile Website
View Site in Mobile | Classic
Share by: