Class Traceparent

java.lang.Object
org.projecthusky.communication.utils.Traceparent

public class Traceparent extends Object
A class representing a traceparent.

The traceId value is managed in the same way as UUID.

Author:
Quentin Ligier
See Also:
  • Constructor Details

    • Traceparent

      public Traceparent(byte version, long traceIdMostSigBits, long traceIdLeastSigBits, long parentId, byte flags)
      Creates a new traceparent.
      Parameters:
      version - The version of the traceparent. 8-bit unsigned integer. Version ff is invalid.
      traceIdMostSigBits - The most significant bits of the traceId. 8-byte unsigned integer.
      traceIdLeastSigBits - The least significant bits of the traceId. 8-byte unsigned integer.
      parentId - The parent id. 8-byte unsigned integer.
      flags - The flags. 8-bit unsigned integer.
  • Method Details

    • random

      public static Traceparent random()
      Generates a random traceparent, with version 0 and flags 0.
    • parse

      public static Traceparent parse(String value)
      Parses a traceparent from a string.
    • version

      public int version()
    • traceId

      public String traceId()
    • parentId

      public String parentId()
    • flags

      public int flags()
    • toString

      public String toString()
      Returns the string representation of this traceparent.
      Overrides:
      toString in class Object
    • withVersion

      public Traceparent withVersion(String version)
      Duplicates this instance with the given version.
    • withTraceId

      public Traceparent withTraceId(String traceId)
      Duplicates this instance with the given trace id.
    • withParentId

      public Traceparent withParentId(String parentId)
      Duplicates this instance with the given parent id.
    • withFlags

      public Traceparent withFlags(String flags)
      Duplicates this instance with the given flags.
    • withRandomParentId

      public Traceparent withRandomParentId()
      Duplicates this instance with a random parent id.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object