Class Span (0.24.2)

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.

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

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.

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.

Stack trace captured at the start of the span.

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

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.

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.



A set of attributes, each in the format [KEY]:[VALUE].

The number of attributes that were discarded. Attributes can be discarded because their keys are too long or because there are too many attributes. If this value is 0 then all attributes are valid.

A pointer from the current span to another span in the same trace or in a different trace. For example, this can be used in batching operations, where a single batch handler processes multiple requests from different traces or when the handler receives a request from a different project.

The [SPAN_ID] for a span within a trace.

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

A collection of links, which are references from this span to a span in the same or different trace.

The number of dropped links after the maximum size was enforced. If this value is 0, then no links were dropped.


A time-stamped annotation or message event in the Span.

A TimeEvent can contain either an Annotation object or a MessageEvent object, but not both.

An event describing a message sent/received between Spans.


A collection of TimeEvent\ s. A TimeEvent is a time-stamped annotation on the span, consisting of either user-supplied key:value pairs, or details of a message sent/received between Spans.

The number of dropped annotations in all the included time events. If the value is 0, then no annotations were dropped.