未验证 提交 8cf42e72 编写于 作者: 彭勇升 pengys 提交者: GitHub

Merge pull request #723 from apache/feature/segment-limit-log

Add warning log outputs, if too many spans created in one segment.
...@@ -35,6 +35,8 @@ import org.apache.skywalking.apm.agent.core.context.trace.WithPeerInfo; ...@@ -35,6 +35,8 @@ import org.apache.skywalking.apm.agent.core.context.trace.WithPeerInfo;
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryManager; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryManager;
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil;
import org.apache.skywalking.apm.agent.core.dictionary.PossibleFound; import org.apache.skywalking.apm.agent.core.dictionary.PossibleFound;
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.sampling.SamplingService; import org.apache.skywalking.apm.agent.core.sampling.SamplingService;
/** /**
...@@ -52,6 +54,9 @@ import org.apache.skywalking.apm.agent.core.sampling.SamplingService; ...@@ -52,6 +54,9 @@ import org.apache.skywalking.apm.agent.core.sampling.SamplingService;
* @author zhang xin * @author zhang xin
*/ */
public class TracingContext implements AbstractTracerContext { public class TracingContext implements AbstractTracerContext {
private static final ILog logger = LogManager.getLogger(TracingContext.class);
private long lastWarningTimestamp = 0;
/** /**
* @see {@link SamplingService} * @see {@link SamplingService}
*/ */
...@@ -506,6 +511,16 @@ public class TracingContext implements AbstractTracerContext { ...@@ -506,6 +511,16 @@ public class TracingContext implements AbstractTracerContext {
} }
private boolean isLimitMechanismWorking() { private boolean isLimitMechanismWorking() {
return spanIdGenerator >= Config.Agent.SPAN_LIMIT_PER_SEGMENT; if (spanIdGenerator >= Config.Agent.SPAN_LIMIT_PER_SEGMENT) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - lastWarningTimestamp > 30 * 1000) {
logger.warn(new RuntimeException("Shadow tracing context. Thread dump"), "More than {} spans required to create",
Config.Agent.SPAN_LIMIT_PER_SEGMENT);
lastWarningTimestamp = currentTimeMillis;
}
return true;
} else {
return false;
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册