• Use TraceContext.traceId() API to obtain traceId.
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
...

modelAndView.addObject("traceId", TraceContext.traceId());
  • Use TraceContext.segmentId() API to obtain segmentId.
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
...

modelAndView.addObject("segmentId", TraceContext.segmentId());
  • Use TraceContext.spanId() API to obtain spanId.
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
...

modelAndView.addObject("spanId", TraceContext.spanId());

Sample codes only