woshishitou commented on issue #6900:
URL: https://github.com/apache/skywalking/issues/6900#issuecomment-1001298651


   > 
   
   `            // 
获取skywalking设置到exchange中的span实例,并使用反射获取其owner字段(该字段从父类的父类继承而来,类型为TracingContext)
               Object entrySpanInstance = 
exchange.getAttributes().get("SKYWALING_SPAN");
               Class<?> entrySpanClazz = 
entrySpanInstance.getClass().getSuperclass().getSuperclass();
               Field field = entrySpanClazz.getDeclaredField("owner");
               // 利用反射调用owner的getReadablePrimaryTraceId()方法,以获取traceId
               field.setAccessible(true);
               Object ownerInstance = field.get(entrySpanInstance);
               Class<?> ownerClazz = ownerInstance.getClass();
               Method getTraceId = 
ownerClazz.getMethod("getReadablePrimaryTraceId");
               String traceId = (String) getTraceId.invoke(ownerInstance);
   `


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to