From e0b7306e5ddae91adc0faf09f505dee9401ded01 Mon Sep 17 00:00:00 2001 From: zhangwei <26432832+Arugal@users.noreply.github.com> Date: Sun, 26 May 2019 00:14:21 +0800 Subject: [PATCH] Determine EXTEND_SERVICE before invoker createTraceContext (#2755) --- .../skywalking/apm/agent/core/context/ContextManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java index 2dbdb3574..1537bbcf0 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java @@ -44,9 +44,6 @@ public class ContextManager implements BootService { private static AbstractTracerContext getOrCreate(String operationName, boolean forceSampling) { AbstractTracerContext context = CONTEXT.get(); - if (EXTEND_SERVICE == null) { - EXTEND_SERVICE = ServiceManager.INSTANCE.findService(ContextManagerExtendService.class); - } if (context == null) { if (StringUtil.isEmpty(operationName)) { if (logger.isDebugEnable()) { @@ -57,6 +54,9 @@ public class ContextManager implements BootService { if (RemoteDownstreamConfig.Agent.SERVICE_ID != DictionaryUtil.nullValue() && RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID != DictionaryUtil.nullValue() ) { + if (EXTEND_SERVICE == null) { + EXTEND_SERVICE = ServiceManager.INSTANCE.findService(ContextManagerExtendService.class); + } context = EXTEND_SERVICE.createTraceContext(operationName, forceSampling); } else { /**