You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/10/07 15:25:58 UTC

[activemq-artemis] branch master updated: ARTEMIS-2936 Adding logging.info on when to enable trace on critical analyzer

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 8fe4bfb  ARTEMIS-2936 Adding logging.info on when to enable trace on critical analyzer
     new 5be917f  This closes #3292
8fe4bfb is described below

commit 8fe4bfb29a2d3668ef28b59be4f54bc06e30e8f7
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Wed Oct 7 10:05:41 2020 -0400

    ARTEMIS-2936 Adding logging.info on when to enable trace on critical analyzer
---
 .../activemq/artemis/cli/commands/etc/logging.properties       |  7 ++++++-
 .../activemq/artemis/utils/critical/CriticalMeasure.java       |  2 +-
 .../activemq/artemis/core/server/ActiveMQServerLogger.java     |  4 ++++
 .../activemq/artemis/core/server/impl/ActiveMQServerImpl.java  | 10 ++++++++++
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties
index 1bfc4dc..2a2ab34 100644
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties
@@ -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
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java
index a626f62..a32fe8c 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java
@@ -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);
             }
          }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 66a9a38..fa4681a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -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();
 }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 2ef94f8..e0c8636 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -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