Class Sw8

java.lang.Object
codes.grow.packages.skywalking.Sw8

public final class Sw8 extends Object
SkyWalking cross-process propagation headers sw8 (v3) and sw8-correlation: encoding, decoding and the context helpers used by Sw8Propagator.

sw8 = sample-b64(traceId)-b64(parentSegment)-parentSpanId-b64(service)- b64(instance)-b64(endpoint)-b64(peer) (8 fields, standard Base64 with padding); sw8-correlation = b64(key):b64(value),....

  • Field Details

  • Method Details

    • encode

      public static String encode(Sw8Context ctx)
      Encodes an sw8 header value.
      Parameters:
      ctx - context
      Returns:
      the header value
    • decode

      public static Optional<Sw8Context> decode(String header)
      Decodes an sw8 header value.
      Parameters:
      header - header value (may be null)
      Returns:
      the context, or empty when the header is malformed (wrong field count, bad Base64, sample not 0/1, non-integer span id, empty trace or segment id)
    • encodeCorrelation

      public static String encodeCorrelation(Map<String,String> entries)
      Encodes sw8-correlation in map order.
      Parameters:
      entries - key/value pairs
      Returns:
      the header value
    • decodeCorrelation

      public static Map<String,String> decodeCorrelation(String header)
      Decodes sw8-correlation; malformed entries are skipped.
      Parameters:
      header - header value (may be null)
      Returns:
      the entries in header order
    • fromContext

      public static Optional<Sw8Context> fromContext(io.opentelemetry.context.Context ctx)
      The sw8 context extracted from an incoming request by Sw8Propagator.
      Parameters:
      ctx - OpenTelemetry context
      Returns:
      the extracted context, or empty
    • withContext

      public static io.opentelemetry.context.Context withContext(io.opentelemetry.context.Context ctx, Sw8Context sw8)
      Returns a context whose outgoing requests carry this native metadata as sw8. The SDK cannot derive native metadata from an OpenTelemetry span; supply it only when you bridge to SkyWalking agents.
      Parameters:
      ctx - OpenTelemetry context
      sw8 - native metadata
      Returns:
      the new context
    • withContext

      public static io.opentelemetry.context.Context withContext(io.opentelemetry.context.Context ctx, Sw8Context sw8, Map<String,String> correlation)
      Like withContext(Context, Sw8Context), also writing sw8-correlation.
      Parameters:
      ctx - OpenTelemetry context
      sw8 - native metadata
      correlation - correlation entries (written as sw8-correlation)
      Returns:
      the new context
    • attributes

      public static Map<String,Object> attributes(Sw8Context sw8)
      Span attributes describing an extracted parent (sw8.parent.*, sw8.peer).
      Parameters:
      sw8 - context
      Returns:
      the attributes