Class Span

  • All Implemented Interfaces:
    com.google.protobuf.Message, com.google.protobuf.MessageLite, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, SpanOrBuilder, Serializable

    public final class Span
    extends com.google.protobuf.GeneratedMessageV3
    implements SpanOrBuilder
     A span represents a single operation within a trace. Spans can be
     nested to form a trace tree. Spans may also be linked to other spans
     from the same or different trace. And form graphs. 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.
     The next id is 17.
     TODO(bdrutu): Add an example.
     
    Protobuf type opencensus.proto.trace.v1.Span
    See Also:
    Serialized Form
    • Method Detail

      • newInstance

        protected Object newInstance​(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
        Overrides:
        newInstance in class com.google.protobuf.GeneratedMessageV3
      • getUnknownFields

        public final com.google.protobuf.UnknownFieldSet getUnknownFields()
        Specified by:
        getUnknownFields in interface com.google.protobuf.MessageOrBuilder
        Overrides:
        getUnknownFields in class com.google.protobuf.GeneratedMessageV3
      • getDescriptor

        public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
      • internalGetFieldAccessorTable

        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3
      • getTraceId

        public com.google.protobuf.ByteString getTraceId()
         A unique identifier for a trace. All spans from the same trace share
         the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes
         is considered invalid.
         This field is semantically required. Receiver should generate new
         random trace_id if empty or invalid trace_id was received.
         This field is required.
         
        bytes trace_id = 1;
        Specified by:
        getTraceId in interface SpanOrBuilder
        Returns:
        The traceId.
      • getSpanId

        public com.google.protobuf.ByteString getSpanId()
         A unique identifier for a span within a trace, assigned when the span
         is created. The ID is an 8-byte array. An ID with all zeroes is considered
         invalid.
         This field is semantically required. Receiver should generate new
         random span_id if empty or invalid span_id was received.
         This field is required.
         
        bytes span_id = 2;
        Specified by:
        getSpanId in interface SpanOrBuilder
        Returns:
        The spanId.
      • hasTracestate

        public boolean hasTracestate()
         The Tracestate on the span.
         
        .opencensus.proto.trace.v1.Span.Tracestate tracestate = 15;
        Specified by:
        hasTracestate in interface SpanOrBuilder
        Returns:
        Whether the tracestate field is set.
      • getTracestate

        public Span.Tracestate getTracestate()
         The Tracestate on the span.
         
        .opencensus.proto.trace.v1.Span.Tracestate tracestate = 15;
        Specified by:
        getTracestate in interface SpanOrBuilder
        Returns:
        The tracestate.
      • getParentSpanId

        public com.google.protobuf.ByteString getParentSpanId()
         The `span_id` of this span's parent span. If this is a root span, then this
         field must be empty. The ID is an 8-byte array.
         
        bytes parent_span_id = 3;
        Specified by:
        getParentSpanId in interface SpanOrBuilder
        Returns:
        The parentSpanId.
      • hasName

        public boolean hasName()
         A description of the span's operation.
         For example, the 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 at the same call point in an application.
         This makes it easier to correlate spans in different traces.
         This field is semantically required to be set to non-empty string.
         When null or empty string received - receiver may use string "name"
         as a replacement. There might be smarted algorithms implemented by
         receiver to fix the empty span name.
         This field is required.
         
        .opencensus.proto.trace.v1.TruncatableString name = 4;
        Specified by:
        hasName in interface SpanOrBuilder
        Returns:
        Whether the name field is set.
      • getName

        public TruncatableString getName()
         A description of the span's operation.
         For example, the 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 at the same call point in an application.
         This makes it easier to correlate spans in different traces.
         This field is semantically required to be set to non-empty string.
         When null or empty string received - receiver may use string "name"
         as a replacement. There might be smarted algorithms implemented by
         receiver to fix the empty span name.
         This field is required.
         
        .opencensus.proto.trace.v1.TruncatableString name = 4;
        Specified by:
        getName in interface SpanOrBuilder
        Returns:
        The name.
      • getNameOrBuilder

        public TruncatableStringOrBuilder getNameOrBuilder()
         A description of the span's operation.
         For example, the 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 at the same call point in an application.
         This makes it easier to correlate spans in different traces.
         This field is semantically required to be set to non-empty string.
         When null or empty string received - receiver may use string "name"
         as a replacement. There might be smarted algorithms implemented by
         receiver to fix the empty span name.
         This field is required.
         
        .opencensus.proto.trace.v1.TruncatableString name = 4;
        Specified by:
        getNameOrBuilder in interface SpanOrBuilder
      • getKindValue

        public int getKindValue()
         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 queueing latency associated with the span.
         
        .opencensus.proto.trace.v1.Span.SpanKind kind = 14;
        Specified by:
        getKindValue in interface SpanOrBuilder
        Returns:
        The enum numeric value on the wire for kind.
      • getKind

        public Span.SpanKind getKind()
         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 queueing latency associated with the span.
         
        .opencensus.proto.trace.v1.Span.SpanKind kind = 14;
        Specified by:
        getKind in interface SpanOrBuilder
        Returns:
        The kind.
      • hasStartTime

        public boolean hasStartTime()
         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.
         This field is semantically required. When not set on receive -
         receiver should set it to the value of end_time field if it was
         set. Or to the current time if neither was set. It is important to
         keep end_time > start_time for consistency.
         This field is required.
         
        .google.protobuf.Timestamp start_time = 5;
        Specified by:
        hasStartTime in interface SpanOrBuilder
        Returns:
        Whether the startTime field is set.
      • getStartTime

        public com.google.protobuf.Timestamp getStartTime()
         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.
         This field is semantically required. When not set on receive -
         receiver should set it to the value of end_time field if it was
         set. Or to the current time if neither was set. It is important to
         keep end_time > start_time for consistency.
         This field is required.
         
        .google.protobuf.Timestamp start_time = 5;
        Specified by:
        getStartTime in interface SpanOrBuilder
        Returns:
        The startTime.
      • getStartTimeOrBuilder

        public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder()
         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.
         This field is semantically required. When not set on receive -
         receiver should set it to the value of end_time field if it was
         set. Or to the current time if neither was set. It is important to
         keep end_time > start_time for consistency.
         This field is required.
         
        .google.protobuf.Timestamp start_time = 5;
        Specified by:
        getStartTimeOrBuilder in interface SpanOrBuilder
      • hasEndTime

        public boolean hasEndTime()
         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.
         This field is semantically required. When not set on receive -
         receiver should set it to start_time value. It is important to
         keep end_time > start_time for consistency.
         This field is required.
         
        .google.protobuf.Timestamp end_time = 6;
        Specified by:
        hasEndTime in interface SpanOrBuilder
        Returns:
        Whether the endTime field is set.
      • getEndTime

        public com.google.protobuf.Timestamp getEndTime()
         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.
         This field is semantically required. When not set on receive -
         receiver should set it to start_time value. It is important to
         keep end_time > start_time for consistency.
         This field is required.
         
        .google.protobuf.Timestamp end_time = 6;
        Specified by:
        getEndTime in interface SpanOrBuilder
        Returns:
        The endTime.
      • getEndTimeOrBuilder

        public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder()
         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.
         This field is semantically required. When not set on receive -
         receiver should set it to start_time value. It is important to
         keep end_time > start_time for consistency.
         This field is required.
         
        .google.protobuf.Timestamp end_time = 6;
        Specified by:
        getEndTimeOrBuilder in interface SpanOrBuilder
      • hasAttributes

        public boolean hasAttributes()
         A set of attributes on the span.
         
        .opencensus.proto.trace.v1.Span.Attributes attributes = 7;
        Specified by:
        hasAttributes in interface SpanOrBuilder
        Returns:
        Whether the attributes field is set.
      • getAttributes

        public Span.Attributes getAttributes()
         A set of attributes on the span.
         
        .opencensus.proto.trace.v1.Span.Attributes attributes = 7;
        Specified by:
        getAttributes in interface SpanOrBuilder
        Returns:
        The attributes.
      • hasStackTrace

        public boolean hasStackTrace()
         A stack trace captured at the start of the span.
         
        .opencensus.proto.trace.v1.StackTrace stack_trace = 8;
        Specified by:
        hasStackTrace in interface SpanOrBuilder
        Returns:
        Whether the stackTrace field is set.
      • getStackTrace

        public StackTrace getStackTrace()
         A stack trace captured at the start of the span.
         
        .opencensus.proto.trace.v1.StackTrace stack_trace = 8;
        Specified by:
        getStackTrace in interface SpanOrBuilder
        Returns:
        The stackTrace.
      • hasTimeEvents

        public boolean hasTimeEvents()
         The included time events.
         
        .opencensus.proto.trace.v1.Span.TimeEvents time_events = 9;
        Specified by:
        hasTimeEvents in interface SpanOrBuilder
        Returns:
        Whether the timeEvents field is set.
      • getTimeEvents

        public Span.TimeEvents getTimeEvents()
         The included time events.
         
        .opencensus.proto.trace.v1.Span.TimeEvents time_events = 9;
        Specified by:
        getTimeEvents in interface SpanOrBuilder
        Returns:
        The timeEvents.
      • hasLinks

        public boolean hasLinks()
         The included links.
         
        .opencensus.proto.trace.v1.Span.Links links = 10;
        Specified by:
        hasLinks in interface SpanOrBuilder
        Returns:
        Whether the links field is set.
      • getLinks

        public Span.Links getLinks()
         The included links.
         
        .opencensus.proto.trace.v1.Span.Links links = 10;
        Specified by:
        getLinks in interface SpanOrBuilder
        Returns:
        The links.
      • hasStatus

        public boolean hasStatus()
         An optional final status for this span. Semantically when Status
         wasn't set it is means span ended without errors and assume
         Status.Ok (code = 0).
         
        .opencensus.proto.trace.v1.Status status = 11;
        Specified by:
        hasStatus in interface SpanOrBuilder
        Returns:
        Whether the status field is set.
      • getStatus

        public Status getStatus()
         An optional final status for this span. Semantically when Status
         wasn't set it is means span ended without errors and assume
         Status.Ok (code = 0).
         
        .opencensus.proto.trace.v1.Status status = 11;
        Specified by:
        getStatus in interface SpanOrBuilder
        Returns:
        The status.
      • getStatusOrBuilder

        public StatusOrBuilder getStatusOrBuilder()
         An optional final status for this span. Semantically when Status
         wasn't set it is means span ended without errors and assume
         Status.Ok (code = 0).
         
        .opencensus.proto.trace.v1.Status status = 11;
        Specified by:
        getStatusOrBuilder in interface SpanOrBuilder
      • hasResource

        public boolean hasResource()
         An optional resource that is associated with this span. If not set, this span 
         should be part of a batch that does include the resource information, unless resource 
         information is unknown.
         
        .opencensus.proto.resource.v1.Resource resource = 16;
        Specified by:
        hasResource in interface SpanOrBuilder
        Returns:
        Whether the resource field is set.
      • getResource

        public Resource getResource()
         An optional resource that is associated with this span. If not set, this span 
         should be part of a batch that does include the resource information, unless resource 
         information is unknown.
         
        .opencensus.proto.resource.v1.Resource resource = 16;
        Specified by:
        getResource in interface SpanOrBuilder
        Returns:
        The resource.
      • getResourceOrBuilder

        public ResourceOrBuilder getResourceOrBuilder()
         An optional resource that is associated with this span. If not set, this span 
         should be part of a batch that does include the resource information, unless resource 
         information is unknown.
         
        .opencensus.proto.resource.v1.Resource resource = 16;
        Specified by:
        getResourceOrBuilder in interface SpanOrBuilder
      • hasSameProcessAsParentSpan

        public boolean hasSameProcessAsParentSpan()
         A highly recommended but not required flag that identifies when a
         trace crosses a process boundary. True when the parent_span belongs
         to the same process as the current span. This flag is most commonly
         used to indicate the need to adjust time as clocks in different
         processes may not be synchronized.
         
        .google.protobuf.BoolValue same_process_as_parent_span = 12;
        Specified by:
        hasSameProcessAsParentSpan in interface SpanOrBuilder
        Returns:
        Whether the sameProcessAsParentSpan field is set.
      • getSameProcessAsParentSpan

        public com.google.protobuf.BoolValue getSameProcessAsParentSpan()
         A highly recommended but not required flag that identifies when a
         trace crosses a process boundary. True when the parent_span belongs
         to the same process as the current span. This flag is most commonly
         used to indicate the need to adjust time as clocks in different
         processes may not be synchronized.
         
        .google.protobuf.BoolValue same_process_as_parent_span = 12;
        Specified by:
        getSameProcessAsParentSpan in interface SpanOrBuilder
        Returns:
        The sameProcessAsParentSpan.
      • getSameProcessAsParentSpanOrBuilder

        public com.google.protobuf.BoolValueOrBuilder getSameProcessAsParentSpanOrBuilder()
         A highly recommended but not required flag that identifies when a
         trace crosses a process boundary. True when the parent_span belongs
         to the same process as the current span. This flag is most commonly
         used to indicate the need to adjust time as clocks in different
         processes may not be synchronized.
         
        .google.protobuf.BoolValue same_process_as_parent_span = 12;
        Specified by:
        getSameProcessAsParentSpanOrBuilder in interface SpanOrBuilder
      • hasChildSpanCount

        public boolean hasChildSpanCount()
         An optional number of child spans that were generated while this span
         was active. If set, allows an implementation to detect missing child spans.
         
        .google.protobuf.UInt32Value child_span_count = 13;
        Specified by:
        hasChildSpanCount in interface SpanOrBuilder
        Returns:
        Whether the childSpanCount field is set.
      • getChildSpanCount

        public com.google.protobuf.UInt32Value getChildSpanCount()
         An optional number of child spans that were generated while this span
         was active. If set, allows an implementation to detect missing child spans.
         
        .google.protobuf.UInt32Value child_span_count = 13;
        Specified by:
        getChildSpanCount in interface SpanOrBuilder
        Returns:
        The childSpanCount.
      • getChildSpanCountOrBuilder

        public com.google.protobuf.UInt32ValueOrBuilder getChildSpanCountOrBuilder()
         An optional number of child spans that were generated while this span
         was active. If set, allows an implementation to detect missing child spans.
         
        .google.protobuf.UInt32Value child_span_count = 13;
        Specified by:
        getChildSpanCountOrBuilder in interface SpanOrBuilder
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class com.google.protobuf.GeneratedMessageV3
      • writeTo

        public void writeTo​(com.google.protobuf.CodedOutputStream output)
                     throws IOException
        Specified by:
        writeTo in interface com.google.protobuf.MessageLite
        Overrides:
        writeTo in class com.google.protobuf.GeneratedMessageV3
        Throws:
        IOException
      • getSerializedSize

        public int getSerializedSize()
        Specified by:
        getSerializedSize in interface com.google.protobuf.MessageLite
        Overrides:
        getSerializedSize in class com.google.protobuf.GeneratedMessageV3
      • equals

        public boolean equals​(Object obj)
        Specified by:
        equals in interface com.google.protobuf.Message
        Overrides:
        equals in class com.google.protobuf.AbstractMessage
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface com.google.protobuf.Message
        Overrides:
        hashCode in class com.google.protobuf.AbstractMessage
      • parseFrom

        public static Span parseFrom​(ByteBuffer data)
                              throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static Span parseFrom​(ByteBuffer data,
                                     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                              throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static Span parseFrom​(com.google.protobuf.ByteString data)
                              throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static Span parseFrom​(com.google.protobuf.ByteString data,
                                     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                              throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static Span parseFrom​(byte[] data)
                              throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static Span parseFrom​(byte[] data,
                                     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                              throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static Span parseFrom​(com.google.protobuf.CodedInputStream input,
                                     com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                              throws IOException
        Throws:
        IOException
      • newBuilderForType

        public Span.Builder newBuilderForType()
        Specified by:
        newBuilderForType in interface com.google.protobuf.Message
        Specified by:
        newBuilderForType in interface com.google.protobuf.MessageLite
      • toBuilder

        public Span.Builder toBuilder()
        Specified by:
        toBuilder in interface com.google.protobuf.Message
        Specified by:
        toBuilder in interface com.google.protobuf.MessageLite
      • newBuilderForType

        protected Span.Builder newBuilderForType​(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
        Specified by:
        newBuilderForType in class com.google.protobuf.GeneratedMessageV3
      • getDefaultInstance

        public static Span getDefaultInstance()
      • parser

        public static com.google.protobuf.Parser<Span> parser()
      • getParserForType

        public com.google.protobuf.Parser<Span> getParserForType()
        Specified by:
        getParserForType in interface com.google.protobuf.Message
        Specified by:
        getParserForType in interface com.google.protobuf.MessageLite
        Overrides:
        getParserForType in class com.google.protobuf.GeneratedMessageV3
      • getDefaultInstanceForType

        public Span getDefaultInstanceForType()
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder