Stackdriver Trace V2 Client - Class Span (1.8.6)

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

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

Namespace

Google \ Cloud \ Trace \ V2

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. 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. .

↳ 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). 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.

↳ 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, 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. 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. .

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. 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. .

Parameter
Name Description
var string
Returns
Type Description
$this

getSpanId

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

Returns
Type Description
string

setSpanId

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

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.

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.

Parameter
Name Description
var string
Returns
Type Description
$this

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.

Returns
Type Description
Google\Cloud\Trace\V2\TruncatableString|null

hasDisplayName

clearDisplayName

setDisplayName

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.

Parameter
Name Description
var Google\Cloud\Trace\V2\TruncatableString
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.

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.

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.

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.

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.

Returns
Type Description
Google\Cloud\Trace\V2\Span\Attributes|null

hasAttributes

clearAttributes

setAttributes

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

Parameter
Name Description
var Google\Cloud\Trace\V2\Span\Attributes
Returns
Type Description
$this

getStackTrace

Stack trace captured at the start of the span.

Returns
Type Description
Google\Cloud\Trace\V2\StackTrace|null

hasStackTrace

clearStackTrace

setStackTrace

Stack trace captured at the start of the span.

Parameter
Name Description
var Google\Cloud\Trace\V2\StackTrace
Returns
Type Description
$this

getTimeEvents

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

Returns
Type Description
Google\Cloud\Trace\V2\Span\TimeEvents|null

hasTimeEvents

clearTimeEvents

setTimeEvents

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

Parameter
Name Description
var Google\Cloud\Trace\V2\Span\TimeEvents
Returns
Type Description
$this

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

Returns
Type Description
Google\Cloud\Trace\V2\Span\Links|null

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

Parameter
Name Description
var Google\Cloud\Trace\V2\Span\Links
Returns
Type Description
$this

getStatus

Optional. The final status for this span.

Returns
Type Description
Google\Rpc\Status|null

hasStatus

clearStatus

setStatus

Optional. The final status for this span.

Parameter
Name Description
var Google\Rpc\Status
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, Trace is unable to take advantage of this helpful information.

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

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

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

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.

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.

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.

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.

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.

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.

Parameter
Name Description
var int
Returns
Type Description
$this