shenyu plugin fix IgnoredTracerContext traceId NPE (#215)

This commit is contained in:
hutaishi 2022-06-20 22:02:03 +08:00 committed by GitHub
parent 8de87f5556
commit dacdddb1b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -4,7 +4,7 @@ Release Notes.
8.12.0
------------------
* Fix `Shenyu plugin`'s NPE in reading read trace ID when IgnoredTracerContext is used in the context.
#### Documentation

View File

@ -22,6 +22,7 @@ import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.context.ids.DistributedTraceId;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.tag.Tags.HTTP;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
@ -75,7 +76,8 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou
HTTP.METHOD.set(span, exchange.getRequest().getMethodValue());
ContextSnapshot snapshot = ContextManager.capture();
exchange.getAttributes().put(SHENYU_AGENT_TRACE_ID, snapshot.getTraceId().getId());
exchange.getAttributes().put(SHENYU_AGENT_TRACE_ID,
Optional.ofNullable(snapshot.getTraceId()).map(DistributedTraceId::getId).orElse(""));
EnhancedInstance instance = getInstance(allArguments[0]);
instance.setSkyWalkingDynamicField(snapshot);
span.prepareForAsync();