From c44bdd316e496d96ba540c485eb475f5ca08c3b4 Mon Sep 17 00:00:00 2001 From: Jerry Duffy Date: Mon, 9 Oct 2023 11:04:43 -0400 Subject: [PATCH 1/2] Additional txn naming logging --- .../com/nr/instrumentation/servlet24/ServletHelper.java | 4 +++- .../com/nr/instrumentation/servlet5/ServletHelper.java | 4 +++- .../com/nr/instrumentation/servlet6/ServletHelper.java | 4 +++- .../agent/instrumentation/SpringControllerUtility.java | 4 ++++ .../src/main/java/com/newrelic/agent/Transaction.java | 4 ++++ .../main/java/com/newrelic/agent/TransactionApiImpl.java | 4 ++++ .../HigherPriorityTransactionNamingPolicy.java | 8 ++++++++ .../SameOrHigherPriorityTransactionNamingPolicy.java | 8 ++++++++ .../agent/transaction/TransactionNamingUtility.java | 9 +++++++++ 9 files changed, 46 insertions(+), 3 deletions(-) diff --git a/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java b/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java index de020e4cf9..c77a75520e 100644 --- a/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java +++ b/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java @@ -184,7 +184,9 @@ private static boolean setTxNameUsingServletName(ServletConfig servletConfig, Se return false; } txName = normalizeServletName(txName, servlet); - NewRelic.getAgent().getLogger().log(Level.FINER, "Setting transaction name using servlet name: {0}", txName); + NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet24/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + + "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", + AgentBridge.getAgent().getTransaction().toString()); AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, NO_OVERRIDE, SERVLET_NAME_CATEGORY, txName); return true; diff --git a/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java b/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java index 4c90756721..bc9dc8822f 100644 --- a/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java +++ b/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java @@ -184,7 +184,9 @@ private static boolean setTxNameUsingServletName(ServletConfig servletConfig, Se return false; } txName = normalizeServletName(txName, servlet); - NewRelic.getAgent().getLogger().log(Level.FINER, "Setting transaction name using servlet name: {0}", txName); + NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet5/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + + "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", + AgentBridge.getAgent().getTransaction().toString()); AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, NO_OVERRIDE, SERVLET_NAME_CATEGORY, txName); return true; diff --git a/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java b/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java index 14605f5b11..d303ce3890 100644 --- a/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java +++ b/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java @@ -181,7 +181,9 @@ private static boolean setTxNameUsingServletName(ServletConfig servletConfig, Se return false; } txName = normalizeServletName(txName, servlet); - NewRelic.getAgent().getLogger().log(Level.FINER, "Setting transaction name using servlet name: {0}", txName); + NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet6/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + + "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", + AgentBridge.getAgent().getTransaction().toString()); AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, NO_OVERRIDE, SERVLET_NAME_CATEGORY, txName); return true; diff --git a/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java b/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java index d73ec465c9..6446b3a9b8 100644 --- a/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java +++ b/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java @@ -10,6 +10,7 @@ import com.newrelic.agent.bridge.AgentBridge; import com.newrelic.agent.bridge.Transaction; import com.newrelic.agent.bridge.TransactionNamePriority; +import com.newrelic.api.agent.NewRelic; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -80,6 +81,9 @@ public static void processAnnotations(Transaction transaction, RequestMethod[] m AgentBridge.getAgent().getLogger().log(Level.FINE, "No path was specified for SpringController {0}", matchedAnnotationClass.getName()); } else { String fullPath = SpringControllerUtility.getPath(rootPath, methodPath, httpMethod); + NewRelic.getAgent().getLogger().log(Level.FINEST, "SpringControllerUtility::processAnnotations (4.3.0): calling transaction.setTransactionName to [{0}] " + + "with FRAMEWORK_HIGH and override true, txn {1}, ", + AgentBridge.getAgent().getTransaction().toString()); transaction.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, true, "SpringController", fullPath); } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java b/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java index 051d129b5a..e774540ee9 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java @@ -738,6 +738,10 @@ public boolean conditionalSetPriorityTransactionName(TransactionNamingPolicy pol synchronized (lock) { MetricNames.recordApiSupportabilityMetric(MetricNames.SUPPORTABILITY_API_SET_TRANSACTION_NAME); + Agent.LOG.log(Level.FINEST, "newrelic.agent.Transaction::conditionalSetPriorityTransactionName: Attempting to set txn name: " + + "TxnNamingPolicy: {0}, name: {1}, category: {2}, TxnNamePriority {3}", + policy.toString(), name, category, priority.toString()); + if (policy.canSetTransactionName(this, priority)) { if (Agent.LOG.isFinestEnabled()) { Agent.LOG.log(Level.FINEST, diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java index d5a5289c3d..528c355728 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java @@ -97,6 +97,8 @@ public boolean registerAsyncActivity(Object asyncContext) { public boolean setTransactionName(TransactionNamePriority namePriority, boolean override, String category, String... parts) { Transaction tx = getTransactionIfExists(); + Agent.LOG.log(Level.FINEST, "newrelic.agent.TransactionApiImpl::setTransactionName (1) - txn: {0}, override: {1}, category: {2}, parts: {3}", + (tx != null ? tx.toString() : "N/A"), override, category, String.join("/", parts)); return (tx != null) ? tx.setTransactionName(namePriority, override, category, parts) : false; } @@ -160,6 +162,8 @@ public void ignoreErrors() { public boolean setTransactionName(com.newrelic.agent.bridge.TransactionNamePriority namePriority, boolean override, String category, String... parts) { Transaction tx = getTransactionIfExists(); + Agent.LOG.log(Level.FINEST, "newrelic.agent.TransactionApiImpl::setTransactionName (2) - txn: {0}, override: {1}, category: {2}, parts: {3}", + (tx != null ? tx.toString() : "N/A"), override, category, String.join("/", parts)); return (tx != null) ? tx.setTransactionName(namePriority, override, category, parts) : false; } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java index 0fc9b6b51d..2697ebbe7c 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java @@ -7,9 +7,12 @@ package com.newrelic.agent.transaction; +import com.newrelic.agent.Agent; import com.newrelic.agent.Transaction; import com.newrelic.agent.bridge.TransactionNamePriority; +import java.util.logging.Level; + class HigherPriorityTransactionNamingPolicy extends TransactionNamingPolicy { HigherPriorityTransactionNamingPolicy() { @@ -20,6 +23,11 @@ public boolean canSetTransactionName(Transaction tx, TransactionNamePriority pri if (priority == null) { return false; } + + Agent.LOG.log(Level.FINEST, "agent.transaction.HigherPriorityTransactionNamingPolicy::canSetTransactionName: " + + "txn: {0}, txnPriorityTxnName: {1}, txnNamingScheme: {2}, priority: {3}", + tx.toString(), tx.getPriorityTransactionName().toString(), tx.getNamingScheme().toString(), priority.toString()); + PriorityTransactionName ptn = tx.getPriorityTransactionName(); return TransactionNamingUtility.comparePriority(priority, ptn.getPriority(), tx.getNamingScheme()) > 0; } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java index 3d5ec2dd14..d8768e4379 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java @@ -7,9 +7,12 @@ package com.newrelic.agent.transaction; +import com.newrelic.agent.Agent; import com.newrelic.agent.Transaction; import com.newrelic.agent.bridge.TransactionNamePriority; +import java.util.logging.Level; + class SameOrHigherPriorityTransactionNamingPolicy extends TransactionNamingPolicy { SameOrHigherPriorityTransactionNamingPolicy() { @@ -20,6 +23,11 @@ public boolean canSetTransactionName(Transaction tx, TransactionNamePriority pri if (priority == null) { return false; } + + Agent.LOG.log(Level.FINEST, "agent.transaction.SameOrHigherPriorityTransactionNamingPolicy::canSetTransactionName: " + + "txn: {0}, txnPriorityTxnName: {1}, txnNamingScheme: {2}, priority: {3}", + tx.toString(), tx.getPriorityTransactionName().toString(), tx.getNamingScheme().toString(), priority.toString()); + PriorityTransactionName ptn = tx.getPriorityTransactionName(); return TransactionNamingUtility.comparePriority(priority, ptn.getPriority(), tx.getNamingScheme()) >= 0; } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java index 68890a136c..564f9073be 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java @@ -7,8 +7,11 @@ package com.newrelic.agent.transaction; +import com.newrelic.agent.Agent; import com.newrelic.agent.bridge.TransactionNamePriority; +import java.util.logging.Level; + public class TransactionNamingUtility { /** * @param one Priority name to compare. @@ -39,9 +42,15 @@ public static boolean isLessThan(TransactionNamePriority one, TransactionNamePri public static int comparePriority(TransactionNamePriority one, TransactionNamePriority two, TransactionNamingScheme scheme) { if (TransactionNamingScheme.RESOURCE_BASED.equals(scheme)) { + Agent.LOG.log(Level.FINEST, "agent.transaction.TransactionNamingUtility::comparePriority: pathPriorityOneValue: {0}, " + + "pathPriorityTwoValue: {1}; return val will be {2}", + one.pathPriority, two.pathPriority, one.pathPriority - two.pathPriority); return one.pathPriority - two.pathPriority; } else { + Agent.LOG.log(Level.FINEST, "agent.transaction.TransactionNamingUtility::comparePriority: legacyPriorityOneValue: {0}, " + + "legacyPriorityTwoValue: {1}; return val will be {2}", + one.legacyPriority, two.legacyPriority, one.legacyPriority - two.legacyPriority); return one.legacyPriority - two.legacyPriority; } } From aa2a7637e976f83e9b62577b0735931dbf517774 Mon Sep 17 00:00:00 2001 From: Jerry Duffy Date: Mon, 16 Oct 2023 11:51:52 -0400 Subject: [PATCH 2/2] Gate new logging with level checks --- .../servlet24/ServletHelper.java | 10 +++++++--- .../instrumentation/servlet5/ServletHelper.java | 12 +++++++++--- .../instrumentation/servlet6/ServletHelper.java | 12 +++++++++--- .../SpringControllerUtility.java | 10 +++++++--- .../java/com/newrelic/agent/Transaction.java | 8 +++++--- .../com/newrelic/agent/TransactionApiImpl.java | 12 ++++++++---- .../HigherPriorityTransactionNamingPolicy.java | 9 ++++++--- ...OrHigherPriorityTransactionNamingPolicy.java | 9 ++++++--- .../transaction/TransactionNamingUtility.java | 17 +++++++++++------ 9 files changed, 68 insertions(+), 31 deletions(-) diff --git a/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java b/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java index c77a75520e..2fd5549878 100644 --- a/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java +++ b/instrumentation/servlet-2.4/src/main/java/com/nr/instrumentation/servlet24/ServletHelper.java @@ -184,9 +184,13 @@ private static boolean setTxNameUsingServletName(ServletConfig servletConfig, Se return false; } txName = normalizeServletName(txName, servlet); - NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet24/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + - "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", - AgentBridge.getAgent().getTransaction().toString()); + + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet24/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + + "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", + AgentBridge.getAgent().getTransaction().toString()); + } + AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, NO_OVERRIDE, SERVLET_NAME_CATEGORY, txName); return true; diff --git a/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java b/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java index bc9dc8822f..39c6955d0c 100644 --- a/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java +++ b/instrumentation/servlet-5.0/src/main/java/com/nr/instrumentation/servlet5/ServletHelper.java @@ -184,9 +184,15 @@ private static boolean setTxNameUsingServletName(ServletConfig servletConfig, Se return false; } txName = normalizeServletName(txName, servlet); - NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet5/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + - "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", - AgentBridge.getAgent().getTransaction().toString()); + + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + NewRelic.getAgent() + .getLogger() + .log(Level.FINEST, "Servlet5/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + + "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", + AgentBridge.getAgent().getTransaction().toString()); + } + AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, NO_OVERRIDE, SERVLET_NAME_CATEGORY, txName); return true; diff --git a/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java b/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java index d303ce3890..16662ad60b 100644 --- a/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java +++ b/instrumentation/servlet-6.0/src/main/java/com/nr/instrumentation/servlet6/ServletHelper.java @@ -181,9 +181,15 @@ private static boolean setTxNameUsingServletName(ServletConfig servletConfig, Se return false; } txName = normalizeServletName(txName, servlet); - NewRelic.getAgent().getLogger().log(Level.FINEST, "Servlet6/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + - "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", - AgentBridge.getAgent().getTransaction().toString()); + + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + NewRelic.getAgent() + .getLogger() + .log(Level.FINEST, "Servlet6/ServletHelper::setTxNameUsingServletName: calling transaction.setTransactionName with " + + "priority: SERVLET_NAME and override false, category: Servlet, txn {0}, ", + AgentBridge.getAgent().getTransaction().toString()); + } + AgentBridge.getAgent().getTransaction().setTransactionName(TransactionNamePriority.SERVLET_NAME, NO_OVERRIDE, SERVLET_NAME_CATEGORY, txName); return true; diff --git a/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java b/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java index 6446b3a9b8..6085193c57 100644 --- a/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java +++ b/instrumentation/spring-4.3.0/src/main/java/com/nr/agent/instrumentation/SpringControllerUtility.java @@ -81,9 +81,13 @@ public static void processAnnotations(Transaction transaction, RequestMethod[] m AgentBridge.getAgent().getLogger().log(Level.FINE, "No path was specified for SpringController {0}", matchedAnnotationClass.getName()); } else { String fullPath = SpringControllerUtility.getPath(rootPath, methodPath, httpMethod); - NewRelic.getAgent().getLogger().log(Level.FINEST, "SpringControllerUtility::processAnnotations (4.3.0): calling transaction.setTransactionName to [{0}] " + - "with FRAMEWORK_HIGH and override true, txn {1}, ", - AgentBridge.getAgent().getTransaction().toString()); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + NewRelic.getAgent() + .getLogger() + .log(Level.FINEST, "SpringControllerUtility::processAnnotations (4.3.0): calling transaction.setTransactionName to [{0}] " + + "with FRAMEWORK_HIGH and override true, txn {1}, ", + AgentBridge.getAgent().getTransaction().toString()); + } transaction.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, true, "SpringController", fullPath); } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java b/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java index e774540ee9..1b6af54e83 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/Transaction.java @@ -738,9 +738,11 @@ public boolean conditionalSetPriorityTransactionName(TransactionNamingPolicy pol synchronized (lock) { MetricNames.recordApiSupportabilityMetric(MetricNames.SUPPORTABILITY_API_SET_TRANSACTION_NAME); - Agent.LOG.log(Level.FINEST, "newrelic.agent.Transaction::conditionalSetPriorityTransactionName: Attempting to set txn name: " + - "TxnNamingPolicy: {0}, name: {1}, category: {2}, TxnNamePriority {3}", - policy.toString(), name, category, priority.toString()); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "newrelic.agent.Transaction::conditionalSetPriorityTransactionName: Attempting to set txn name: " + + "TxnNamingPolicy: {0}, name: {1}, category: {2}, TxnNamePriority {3}", + policy.toString(), name, category, priority.toString()); + } if (policy.canSetTransactionName(this, priority)) { if (Agent.LOG.isFinestEnabled()) { diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java index 528c355728..e6158640f2 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/TransactionApiImpl.java @@ -97,8 +97,10 @@ public boolean registerAsyncActivity(Object asyncContext) { public boolean setTransactionName(TransactionNamePriority namePriority, boolean override, String category, String... parts) { Transaction tx = getTransactionIfExists(); - Agent.LOG.log(Level.FINEST, "newrelic.agent.TransactionApiImpl::setTransactionName (1) - txn: {0}, override: {1}, category: {2}, parts: {3}", - (tx != null ? tx.toString() : "N/A"), override, category, String.join("/", parts)); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "newrelic.agent.TransactionApiImpl::setTransactionName (1) - txn: {0}, override: {1}, category: {2}, parts: {3}", + (tx != null ? tx.toString() : "N/A"), override, category, String.join("/", parts)); + } return (tx != null) ? tx.setTransactionName(namePriority, override, category, parts) : false; } @@ -162,8 +164,10 @@ public void ignoreErrors() { public boolean setTransactionName(com.newrelic.agent.bridge.TransactionNamePriority namePriority, boolean override, String category, String... parts) { Transaction tx = getTransactionIfExists(); - Agent.LOG.log(Level.FINEST, "newrelic.agent.TransactionApiImpl::setTransactionName (2) - txn: {0}, override: {1}, category: {2}, parts: {3}", - (tx != null ? tx.toString() : "N/A"), override, category, String.join("/", parts)); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "newrelic.agent.TransactionApiImpl::setTransactionName (2) - txn: {0}, override: {1}, category: {2}, parts: {3}", + (tx != null ? tx.toString() : "N/A"), override, category, String.join("/", parts)); + } return (tx != null) ? tx.setTransactionName(namePriority, override, category, parts) : false; } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java index 2697ebbe7c..f36540f47f 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/HigherPriorityTransactionNamingPolicy.java @@ -10,6 +10,7 @@ import com.newrelic.agent.Agent; import com.newrelic.agent.Transaction; import com.newrelic.agent.bridge.TransactionNamePriority; +import com.newrelic.api.agent.NewRelic; import java.util.logging.Level; @@ -24,9 +25,11 @@ public boolean canSetTransactionName(Transaction tx, TransactionNamePriority pri return false; } - Agent.LOG.log(Level.FINEST, "agent.transaction.HigherPriorityTransactionNamingPolicy::canSetTransactionName: " + - "txn: {0}, txnPriorityTxnName: {1}, txnNamingScheme: {2}, priority: {3}", - tx.toString(), tx.getPriorityTransactionName().toString(), tx.getNamingScheme().toString(), priority.toString()); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "agent.transaction.HigherPriorityTransactionNamingPolicy::canSetTransactionName: " + + "txn: {0}, txnPriorityTxnName: {1}, txnNamingScheme: {2}, priority: {3}", + tx.toString(), tx.getPriorityTransactionName().toString(), tx.getNamingScheme().toString(), priority.toString()); + } PriorityTransactionName ptn = tx.getPriorityTransactionName(); return TransactionNamingUtility.comparePriority(priority, ptn.getPriority(), tx.getNamingScheme()) > 0; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java index d8768e4379..2f9167e979 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/SameOrHigherPriorityTransactionNamingPolicy.java @@ -10,6 +10,7 @@ import com.newrelic.agent.Agent; import com.newrelic.agent.Transaction; import com.newrelic.agent.bridge.TransactionNamePriority; +import com.newrelic.api.agent.NewRelic; import java.util.logging.Level; @@ -24,9 +25,11 @@ public boolean canSetTransactionName(Transaction tx, TransactionNamePriority pri return false; } - Agent.LOG.log(Level.FINEST, "agent.transaction.SameOrHigherPriorityTransactionNamingPolicy::canSetTransactionName: " + - "txn: {0}, txnPriorityTxnName: {1}, txnNamingScheme: {2}, priority: {3}", - tx.toString(), tx.getPriorityTransactionName().toString(), tx.getNamingScheme().toString(), priority.toString()); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "agent.transaction.SameOrHigherPriorityTransactionNamingPolicy::canSetTransactionName: " + + "txn: {0}, txnPriorityTxnName: {1}, txnNamingScheme: {2}, priority: {3}", + tx.toString(), tx.getPriorityTransactionName().toString(), tx.getNamingScheme().toString(), priority.toString()); + } PriorityTransactionName ptn = tx.getPriorityTransactionName(); return TransactionNamingUtility.comparePriority(priority, ptn.getPriority(), tx.getNamingScheme()) >= 0; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java index 564f9073be..750a78a302 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transaction/TransactionNamingUtility.java @@ -9,6 +9,7 @@ import com.newrelic.agent.Agent; import com.newrelic.agent.bridge.TransactionNamePriority; +import com.newrelic.api.agent.NewRelic; import java.util.logging.Level; @@ -42,15 +43,19 @@ public static boolean isLessThan(TransactionNamePriority one, TransactionNamePri public static int comparePriority(TransactionNamePriority one, TransactionNamePriority two, TransactionNamingScheme scheme) { if (TransactionNamingScheme.RESOURCE_BASED.equals(scheme)) { - Agent.LOG.log(Level.FINEST, "agent.transaction.TransactionNamingUtility::comparePriority: pathPriorityOneValue: {0}, " + - "pathPriorityTwoValue: {1}; return val will be {2}", - one.pathPriority, two.pathPriority, one.pathPriority - two.pathPriority); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "agent.transaction.TransactionNamingUtility::comparePriority: pathPriorityOneValue: {0}, " + + "pathPriorityTwoValue: {1}; return val will be {2}", + one.pathPriority, two.pathPriority, one.pathPriority - two.pathPriority); + } return one.pathPriority - two.pathPriority; } else { - Agent.LOG.log(Level.FINEST, "agent.transaction.TransactionNamingUtility::comparePriority: legacyPriorityOneValue: {0}, " + - "legacyPriorityTwoValue: {1}; return val will be {2}", - one.legacyPriority, two.legacyPriority, one.legacyPriority - two.legacyPriority); + if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { + Agent.LOG.log(Level.FINEST, "agent.transaction.TransactionNamingUtility::comparePriority: legacyPriorityOneValue: {0}, " + + "legacyPriorityTwoValue: {1}; return val will be {2}", + one.legacyPriority, two.legacyPriority, one.legacyPriority - two.legacyPriority); + } return one.legacyPriority - two.legacyPriority; } }