Stackdriver Trace V2 Client - Class Span (1.6.5)

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
NameDescription
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
TypeDescription
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
NameDescription
var string
Returns
TypeDescription
$this

getSpanId

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

Returns
TypeDescription
string

setSpanId

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

Parameter
NameDescription
var string
Returns
TypeDescription
$this

getParentSpanId

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

Returns
TypeDescription
string

setParentSpanId

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

Parameter
NameDescription
var string
Returns
TypeDescription
$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
TypeDescription
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
NameDescription
var Google\Cloud\Trace\V2\TruncatableString
Returns
TypeDescription
$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
TypeDescription
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
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$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
TypeDescription
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
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getAttributes

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

Returns
TypeDescription
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
NameDescription
var Google\Cloud\Trace\V2\Span\Attributes
Returns
TypeDescription
$this

getStackTrace

Stack trace captured at the start of the span.

Returns
TypeDescription
Google\Cloud\Trace\V2\StackTrace|null

hasStackTrace

clearStackTrace

setStackTrace

Stack trace captured at the start of the span.

Parameter
NameDescription
var Google\Cloud\Trace\V2\StackTrace
Returns
TypeDescription
$this

getTimeEvents

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

Returns
TypeDescription
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
NameDescription
var Google\Cloud\Trace\V2\Span\TimeEvents
Returns
TypeDescription
$this

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

Returns
TypeDescription
Google\Cloud\Trace\V2\Span\Links|null

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

Parameter
NameDescription
var Google\Cloud\Trace\V2\Span\Links
Returns
TypeDescription
$this

getStatus

Optional. The final status for this span.

Returns
TypeDescription
Google\Rpc\Status|null

hasStatus

clearStatus

setStatus

Optional. The final status for this span.

Parameter
NameDescription
var Google\Rpc\Status
Returns
TypeDescription
$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
TypeDescription
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
TypeDescription
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
NameDescription
var Google\Protobuf\BoolValue
Returns
TypeDescription
$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
NameDescription
var bool|null
Returns
TypeDescription
$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
TypeDescription
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
TypeDescription
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
NameDescription
var Google\Protobuf\Int32Value
Returns
TypeDescription
$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
NameDescription
var int|null
Returns
TypeDescription
$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
TypeDescription
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
NameDescription
var int
Returns
TypeDescription
$this