ARTEMIS-2936 Adding logging.info on when to enable trace on critical analyzer

This commit is contained in:
Clebert Suconic 2020-10-07 10:05:41 -04:00
parent 74dfd19afa
commit 8fe4bfb29a
4 changed files with 21 additions and 2 deletions

View File

@ -17,7 +17,7 @@
# Additional logger names to configure (root logger is always configured)
# Root logger option
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message,org.apache.activemq.audit.resource
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.utils.critical,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message,org.apache.activemq.audit.resource
# Root logger level
logger.level=INFO
@ -25,6 +25,11 @@ logger.level=INFO
logger.org.apache.activemq.artemis.core.server.level=INFO
logger.org.apache.activemq.artemis.journal.level=INFO
logger.org.apache.activemq.artemis.utils.level=INFO
# if you have issues with CriticalAnalyzer, setting this as TRACE would give you extra troubleshooting information.
# but do not use it regularly as it would incur in some extra CPU usage for this diagnostic.
logger.org.apache.activemq.artemis.utils.critical.level=INFO
logger.org.apache.activemq.artemis.jms.level=INFO
logger.org.apache.activemq.artemis.integration.bootstrap.level=INFO
logger.org.eclipse.jetty.level=WARN

View File

@ -65,7 +65,7 @@ public class CriticalMeasure {
if (analyzer != null) {
long nanoTimeout = analyzer.getTimeoutNanoSeconds();
if (checkExpiration(nanoTimeout, false)) {
logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("entered"));
logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("left"));
logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter);
}
}

View File

@ -2117,4 +2117,8 @@ public interface ActiveMQServerLogger extends BasicLogger {
@LogMessage(level = Logger.Level.ERROR)
@Message(id = 224106, value = "failed to remove transaction, xid:{0}", format = Message.Format.MESSAGE_FORMAT)
void errorRemovingTX(@Cause Exception e, Xid xid);
@LogMessage(level = Logger.Level.INFO)
@Message(id = 224107, value = "The Critical Analyzer detected slow paths on the broker. It is recommended that you enable trace logs on org.apache.activemq.artemis.utils.critical while you troubleshoot this issue. You should disable the trace logs when you have finished troubleshooting.", format = Message.Format.MESSAGE_FORMAT)
void enableTraceForCriticalAnalyzer();
}

View File

@ -699,6 +699,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
case HALT:
criticalAction = criticalComponent -> {
checkCriticalAnalyzerLogging();
ActiveMQServerLogger.LOGGER.criticalSystemHalt(criticalComponent);
threadDump();
@ -711,6 +712,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
case SHUTDOWN:
criticalAction = criticalComponent -> {
checkCriticalAnalyzerLogging();
ActiveMQServerLogger.LOGGER.criticalSystemShutdown(criticalComponent);
threadDump();
@ -736,6 +738,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
break;
case LOG:
criticalAction = criticalComponent -> {
checkCriticalAnalyzerLogging();
ActiveMQServerLogger.LOGGER.criticalSystemLog(criticalComponent);
threadDump();
sendCriticalNotification(criticalComponent);
@ -746,6 +749,13 @@ public class ActiveMQServerImpl implements ActiveMQServer {
analyzer.addAction(criticalAction);
}
private static void checkCriticalAnalyzerLogging() {
Logger criticalLogger = Logger.getLogger("org.apache.activemq.artemis.utils.critical");
if (!criticalLogger.isTraceEnabled()) {
ActiveMQServerLogger.LOGGER.enableTraceForCriticalAnalyzer();
}
}
private void sendCriticalNotification(final CriticalComponent criticalComponent) {
// on the case of a critical failure, -1 cannot simply means forever.
// in case graceful is -1, we will set it to 30 seconds