Record Class NativeSpan

java.lang.Object
java.lang.Record
codes.grow.packages.skywalking.NativeSpan
Record Components:
traceId - native trace id (for example <hex>.<n>.<ms>)
segmentId - segment id
spanId - span id within the segment
parentSpanId - parent within the segment, −1 for the segment root
refs - cross-segment parents
serviceCode - service name
serviceInstanceName - instance name
startTime - start (epoch ms)
endTime - end (epoch ms)
endpointName - endpoint (operation) name
type - Entry, Exit or Local
peer - remote address of exit spans
component - component name
isError - whether the span failed
layer - layer (Http, Database, ...)
tags - tags
logs - span logs

public record NativeSpan(String traceId, String segmentId, int spanId, int parentSpanId, List<NativeSpanRef> refs, String serviceCode, String serviceInstanceName, long startTime, long endTime, String endpointName, String type, String peer, String component, boolean isError, String layer, List<KeyValue> tags, List<NativeSpanLog> logs) extends Record
A span as SkyWalking stores it (agents, /v3/segments), read through GraphQL. Ids are opaque strings; a span is identified by (segmentId, spanId); parentSpanId −1 marks the segment root whose parent, if any, is refs[0]. Times are epoch milliseconds.
  • Field Details

  • Constructor Details

    • NativeSpan

      public NativeSpan(String traceId, String segmentId, int spanId, int parentSpanId, List<NativeSpanRef> refs, String serviceCode, String serviceInstanceName, long startTime, long endTime, String endpointName, String type, String peer, String component, boolean isError, String layer, List<KeyValue> tags, List<NativeSpanLog> logs)
      Copies the lists and normalises nulls.
      Parameters:
      traceId - trace id
      segmentId - segment id
      spanId - span id
      parentSpanId - parent span id
      refs - refs
      serviceCode - service
      serviceInstanceName - instance
      startTime - start
      endTime - end
      endpointName - endpoint
      type - type
      peer - peer
      component - component
      isError - error flag
      layer - layer
      tags - tags
      logs - logs
  • Method Details

    • fromJson

      public static NativeSpan fromJson(com.fasterxml.jackson.databind.JsonNode s)
      Decodes one span of a GraphQL response (missing fields get neutral defaults).
      Parameters:
      s - JSON object
      Returns:
      the span
    • spanKey

      public static String spanKey(String segmentId, int spanId)
      The SPEC span id of a native span.
      Parameters:
      segmentId - segment id
      spanId - span id within the segment
      Returns:
      <segmentId>-<spanId>
    • toSpan

      public Span toSpan()
      Converts to the SPEC model: trace id verbatim; span id <segmentId>-<spanId>; the parent is the same segment's parent span when parentSpanId >= 0, else refs[0]; further refs become links (attribute sw.ref_type); kind Entry → server, Exit → client, Local → internal (other: unspecified); name = endpoint name; times ms → µs; status error when isError; attributes = tags plus sw.component, sw.layer, sw.peer, sw.service_instance (when set); span logs become events (name = the event value, else log).
      Returns:
      the span
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • traceId

      public String traceId()
      Returns the value of the traceId record component.
      Returns:
      the value of the traceId record component
    • segmentId

      public String segmentId()
      Returns the value of the segmentId record component.
      Returns:
      the value of the segmentId record component
    • spanId

      public int spanId()
      Returns the value of the spanId record component.
      Returns:
      the value of the spanId record component
    • parentSpanId

      public int parentSpanId()
      Returns the value of the parentSpanId record component.
      Returns:
      the value of the parentSpanId record component
    • refs

      public List<NativeSpanRef> refs()
      Returns the value of the refs record component.
      Returns:
      the value of the refs record component
    • serviceCode

      public String serviceCode()
      Returns the value of the serviceCode record component.
      Returns:
      the value of the serviceCode record component
    • serviceInstanceName

      public String serviceInstanceName()
      Returns the value of the serviceInstanceName record component.
      Returns:
      the value of the serviceInstanceName record component
    • startTime

      public long startTime()
      Returns the value of the startTime record component.
      Returns:
      the value of the startTime record component
    • endTime

      public long endTime()
      Returns the value of the endTime record component.
      Returns:
      the value of the endTime record component
    • endpointName

      public String endpointName()
      Returns the value of the endpointName record component.
      Returns:
      the value of the endpointName record component
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • peer

      public String peer()
      Returns the value of the peer record component.
      Returns:
      the value of the peer record component
    • component

      public String component()
      Returns the value of the component record component.
      Returns:
      the value of the component record component
    • isError

      public boolean isError()
      Returns the value of the isError record component.
      Returns:
      the value of the isError record component
    • layer

      public String layer()
      Returns the value of the layer record component.
      Returns:
      the value of the layer record component
    • tags

      public List<KeyValue> tags()
      Returns the value of the tags record component.
      Returns:
      the value of the tags record component
    • logs

      public List<NativeSpanLog> logs()
      Returns the value of the logs record component.
      Returns:
      the value of the logs record component