diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/TransactionData.java b/newrelic-agent/src/main/java/com/newrelic/agent/TransactionData.java index db5ef430f6..96f1b7f181 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/TransactionData.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/TransactionData.java @@ -9,6 +9,7 @@ import com.newrelic.agent.attributes.AttributesService; import com.newrelic.api.agent.Logs; +import com.newrelic.api.agent.NewRelic; import com.newrelic.api.agent.TransportType; import com.newrelic.agent.config.AgentConfig; import com.newrelic.agent.config.AgentConfigImpl; @@ -31,6 +32,7 @@ import java.util.Collection; import java.util.Map; import java.util.Set; +import java.util.logging.Level; public class TransactionData { private final Transaction tx; @@ -166,6 +168,10 @@ public boolean hasReportableErrorThatIsNotIgnored() { return tx.isErrorReportableAndNotIgnored(); } + public boolean hasErrorThatIsNotExpected() { + return tx.isErrorNotExpected(); + } + /** * A rough approximation of the transaction size (how much memory we are using with our tracers) */ @@ -257,11 +263,20 @@ public ApdexPerfZone getApdexPerfZone() { if (!isWebTransaction() && !tx.getAgentConfig().isApdexTSet(getPriorityTransactionName().getName())) { return null; } + + if (isApdexFrustrating()) { + return ApdexPerfZone.FRUSTRATING; + } + long responseTimeInMillis = tx.getTransactionTimer().getResponseTimeInMilliseconds() + tx.getExternalTime(); long apdexTInMillis = tx.getAgentConfig().getApdexTInMillis(getPriorityTransactionName().getName()); return ApdexPerfZoneDetermination.getZone(responseTimeInMillis, apdexTInMillis); } + public boolean isApdexFrustrating() { + return hasReportableErrorThatIsNotIgnored() && hasErrorThatIsNotExpected(); + } + public String parentType() { if (!receivedInboundDistributedPayload()) { return null; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/TransactionDataTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/TransactionDataTest.java index 56161f9d3e..4fec090761 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/TransactionDataTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/TransactionDataTest.java @@ -13,6 +13,7 @@ import com.newrelic.agent.config.AgentConfigImpl; import com.newrelic.agent.config.TransactionTracerConfig; import com.newrelic.agent.dispatchers.Dispatcher; +import com.newrelic.agent.model.ApdexPerfZone; import com.newrelic.agent.service.ServiceFactory; import com.newrelic.agent.sql.SlowQueryListener; import com.newrelic.agent.tracers.Tracer; @@ -327,4 +328,21 @@ public void toString2() { Assert.assertEquals(MessageFormat.format(" {0}ms {1}", String.valueOf(expected), ex), result); } + @Test + public void isApdexFrustrating_returnsTrue_whenErrorIsPresent() { + Mockito.when(tx.isErrorReportableAndNotIgnored()).thenReturn(true); + Mockito.when(tx.isErrorNotExpected()).thenReturn(true); + + TransactionData txd = getTxData(tx); + Assert.assertTrue(txd.isApdexFrustrating()); + } + + @Test + public void isApdexFrustrating_returnsFalse_whenNoErrorIsPresent() { + Mockito.when(tx.isErrorReportableAndNotIgnored()).thenReturn(false); + Mockito.when(tx.isErrorNotExpected()).thenReturn(false); + + TransactionData txd = getTxData(tx); + Assert.assertFalse(txd.isApdexFrustrating()); + } }