Class TraceContext

java.lang.Object
org.apache.skywalking.apm.toolkit.trace.TraceContext

public class TraceContext extends Object
Try to access the sky-walking tracer context. The context is not existed, always. only the middleware, component, or rpc-framework are supported in the current invoke stack, in the same thread, the context will be available.

  • Constructor Details

    • TraceContext

      public TraceContext()
  • Method Details

    • traceId

      public static String traceId()
      Try to get the traceId of current trace context.
      Returns:
      traceId, if it exists, or empty String.
    • segmentId

      public static String segmentId()
      Try to get the segmentId of current trace context.
      Returns:
      segmentId, if it exists, or empty String.
    • spanId

      public static int spanId()
      Try to get the spanId of current trace context. The spanId is a negative number when the trace context is missing.
      Returns:
      spanId, if it exists, or empty String.
    • getCorrelation

      public static Optional<String> getCorrelation(String key)
      Try to get the custom value from trace context.
      Returns:
      custom data value.
    • putCorrelation

      public static Optional<String> putCorrelation(String key, String value)
      Put the custom key/value into trace context.
      Returns:
      previous value if it exists.