From 53dc9bbd1d96875311fa00c0e016e4a74e59d06b Mon Sep 17 00:00:00 2001 From: tbradellis Date: Wed, 17 Nov 2021 22:30:10 -0800 Subject: [PATCH] check response and throwable --- .../agent/errors/ErrorServiceImpl.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/errors/ErrorServiceImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/errors/ErrorServiceImpl.java index 8cbc36df9e..a31329b6bc 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/errors/ErrorServiceImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/errors/ErrorServiceImpl.java @@ -8,8 +8,21 @@ package com.newrelic.agent.errors; import com.google.common.annotations.VisibleForTesting; -import com.newrelic.agent.*; -import com.newrelic.agent.config.*; +import com.newrelic.agent.Agent; +import com.newrelic.agent.HarvestListener; +import com.newrelic.agent.Harvestable; +import com.newrelic.agent.MetricNames; +import com.newrelic.agent.Transaction; +import com.newrelic.agent.TransactionActivity; +import com.newrelic.agent.TransactionData; +import com.newrelic.agent.TransactionErrorPriority; +import com.newrelic.agent.TransactionListener; +import com.newrelic.agent.config.AgentConfig; +import com.newrelic.agent.config.AgentConfigImpl; +import com.newrelic.agent.config.AgentConfigListener; +import com.newrelic.agent.config.DistributedTracingConfig; +import com.newrelic.agent.config.ErrorCollectorConfig; +import com.newrelic.agent.config.StripExceptionConfig; import com.newrelic.agent.instrumentation.PointCut; import com.newrelic.agent.instrumentation.methodmatchers.InvalidMethodDescriptor; import com.newrelic.agent.instrumentation.yaml.PointCutFactory; @@ -28,7 +41,12 @@ import java.net.HttpURLConnection; import java.text.MessageFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -438,7 +456,9 @@ private void noticeTransaction(TransactionData td, TransactionStats transactionS private TracedError createTracedError(final String theAppName, TransactionData td, Throwable throwable, int responseStatus, String statusMessage) { TracedError error; // noticeError(expected = true)? - boolean markedExpected = td.getThrowable() == null ? false : td.getThrowable().expected; + boolean responseStatusExpected = errorCollectorConfig.getExpectedStatusCodes().contains(responseStatus); + boolean throwableExpected = td.getThrowable() == null ? false : td.getThrowable().expected; + boolean markedExpected = responseStatusExpected || throwableExpected; Map joinedIntrinsics = new HashMap<>(td.getIntrinsicAttributes()); DistributedTraceService distributedTraceService = ServiceFactory.getDistributedTraceService();