Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dt on by default #486

Merged
merged 38 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c450c9f
Enable DT by default
jasonjkeller Sep 15, 2021
4b6507d
change default max spans and make it configurable
XiXiaPdx Sep 16, 2021
dd1ff87
remove unused constants
XiXiaPdx Sep 16, 2021
d960ee4
add tests
XiXiaPdx Sep 16, 2021
c9c7be2
remove server side test
XiXiaPdx Sep 16, 2021
ef93c6f
update span config with server side prop
XiXiaPdx Sep 16, 2021
46ae714
a bit of clean up
XiXiaPdx Sep 16, 2021
fd0e619
refactor type and method name
XiXiaPdx Sep 16, 2021
4c497a1
send span limit metric
XiXiaPdx Sep 16, 2021
d101ced
add and use SpanHarvestConfig to set limits
XiXiaPdx Sep 16, 2021
734821e
add test to confirm span config max samples updated by server prop
XiXiaPdx Sep 16, 2021
482e86e
remove not thrown exception in signatures and simplify
XiXiaPdx Sep 16, 2021
27f37a4
Clean up ExternalAsyncTest
jasonjkeller Sep 17, 2021
8d13552
Fix ExternalAsyncTest by disabling DT and enabling CAT
jasonjkeller Sep 17, 2021
af16ff2
Fix APISupportabilityTest by disabling DT and enabling CAT
jasonjkeller Sep 17, 2021
041e981
Fix APITest by disabling DT and enabling CAT
jasonjkeller Sep 17, 2021
7efb3af
Fix CrossProcessStateCatApiTest by disabling DT and enabling CAT
jasonjkeller Sep 20, 2021
2a50943
Fix InboundHeaderStateTest by disabling DT and enabling CAT
jasonjkeller Sep 20, 2021
be7a61c
Fix BrowserConfigTest by disabling DT and enabling CAT
jasonjkeller Sep 20, 2021
d928ee5
Fix ErrorServiceTest by setting correct intrinsics asserts when DT is…
jasonjkeller Sep 20, 2021
7c43976
Fix TransactionTest by setting correct intrinsics when DT is enabled
jasonjkeller Sep 21, 2021
eb0c0d4
Fix TransactionEventTest by asserting that CAT attributes aren't pres…
jasonjkeller Sep 21, 2021
d6753cf
Remove comment left by mistake
jasonjkeller Sep 21, 2021
3866aa6
Fix TransactionTraceTest by disabling DT and enabling CAT
jasonjkeller Sep 21, 2021
17522ca
Fix AbstractPriorityTransactionNamingPolicyTest by disabling DT and e…
jasonjkeller Sep 21, 2021
50a8650
Fix HigherPriorityTransactionNamingPolicyTest by disabling DT and ena…
jasonjkeller Sep 21, 2021
4cb11bf
Fix SameOrHigherPriorityTransactionNamingPolicyTest by disabling DT a…
jasonjkeller Sep 21, 2021
ee3e25b
Trigger tests
jasonjkeller Sep 21, 2021
c640840
Merge pull request #439 from newrelic/enable-dt-by-default
XiXiaPdx Sep 23, 2021
8d6d510
Merge branch 'main' of https://github.com/newrelic/newrelic-java-agen…
XiXiaPdx Sep 23, 2021
401baaa
Merge branch 'dt-on-by-default' into span-max-samples
XiXiaPdx Sep 23, 2021
6ce4d2a
Merge pull request #443 from newrelic/span-max-samples
XiXiaPdx Sep 23, 2021
603735a
Merge branch 'main' of github.com:newrelic/newrelic-java-agent into d…
jasonjkeller Sep 27, 2021
921996b
Add span_events config to default yaml
jasonjkeller Sep 27, 2021
dfbc7cb
Merge pull request #460 from newrelic/update-yaml
jasonjkeller Sep 27, 2021
1530a7a
Deprecate CAT (#465)
meiao Oct 11, 2021
ca75a47
Clean up HarvestServiceImpl
jasonjkeller Oct 18, 2021
d49a02e
Update default yaml
jasonjkeller Oct 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void verifyCpu(long minCpu) {
Assert.assertTrue("The cpu should be greater than 0", val > 0);
Assert.assertTrue("The cpu should be greater than the expeted min value " + minCpu, val > minCpu);

long cpuTime = 0l;
long cpuTime = 0L;
Collection<Tracer> tracers = new HashSet<>();
tracers.add(data.getRootTracer());
tracers.addAll(data.getTracers());
Expand Down Expand Up @@ -241,8 +241,7 @@ private void verifyGivenTransactionSegmentBreadthFirst(TransactionSegment segmen
Assert.assertEquals("ROOT", segment.getMetricName());
Assert.assertNotNull(segment.getTraceParameters().get("async_context"));

Queue<TransactionSegment> segments = new LinkedList<>();
segments.addAll(segment.getChildren());
Queue<TransactionSegment> segments = new LinkedList<>(segment.getChildren());
int index = 0;
while (!segments.isEmpty()) {
TransactionSegment seg = segments.poll();
Expand All @@ -266,8 +265,7 @@ public void verifyTransactionSegmentNodesWithExecContext(Map<String, String> met
TransactionTrace trace = TransactionTrace.getTransactionTrace(data);
TransactionSegment root = trace.getRootSegment();

Queue<TransactionSegment> segments = new LinkedList<>();
segments.addAll(root.getChildren());
Queue<TransactionSegment> segments = new LinkedList<>(root.getChildren());
int index = 0;
while (!segments.isEmpty()) {
TransactionSegment seg = segments.poll();
Expand All @@ -289,8 +287,7 @@ public void verifyTransactionSegmentsChildren(String parent, String... children)
TransactionTrace trace = TransactionTrace.getTransactionTrace(data);
TransactionSegment root = trace.getRootSegment();

Queue<TransactionSegment> segments = new LinkedList<>();
segments.addAll(root.getChildren());
Queue<TransactionSegment> segments = new LinkedList<>(root.getChildren());
int index = 0;
while (!segments.isEmpty()) {
TransactionSegment seg = segments.poll();
Expand Down Expand Up @@ -374,7 +371,7 @@ private void waitForTransaction() {
while ((System.currentTimeMillis() - start) < 5000 && (data == null || stats == null)) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
}
}
}
Expand All @@ -385,7 +382,7 @@ private void waitForTransactionTimesSet(int timesSet) {
while ((System.currentTimeMillis() - start) < 5000 && (data == null || stats == null || this.timesSet != timesSet)) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
}
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.newrelic.agent.TransactionData;
import com.newrelic.agent.TransactionStatsListener;
import com.newrelic.agent.async.ExternalAsyncTest;
import com.newrelic.agent.bridge.AgentBridge;
import com.newrelic.agent.bridge.TracedActivity;
import com.newrelic.agent.service.ServiceFactory;
Expand All @@ -25,6 +26,8 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import test.newrelic.EnvironmentHolderSettingsGenerator;
import test.newrelic.test.agent.EnvironmentHolder;

import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -35,6 +38,8 @@ public class APISupportabilityTest implements TransactionStatsListener {

private TransactionData data;
private TransactionStats stats;
private static final String CONFIG_FILE = "configs/cross_app_tracing_test.yml";
private static final ClassLoader CLASS_LOADER = APISupportabilityTest.class.getClassLoader();

@Before
public void before() throws Exception {
Expand All @@ -48,6 +53,13 @@ public void after() {
ServiceFactory.getTransactionService().removeTransactionStatsListener(this);
}

public EnvironmentHolder setupEnvironmentHolder(String environment) throws Exception {
EnvironmentHolderSettingsGenerator envHolderSettings = new EnvironmentHolderSettingsGenerator(CONFIG_FILE, environment, CLASS_LOADER);
EnvironmentHolder environmentHolder = new EnvironmentHolder(envHolderSettings);
environmentHolder.setupEnvironment();
return environmentHolder;
}

public static class TokenApiDispatcherTestClass {
@Trace(dispatcher = true)
public void getTokenLinkAndExpire() {
Expand Down Expand Up @@ -858,15 +870,22 @@ public void testNewRelicIgnoreNonDispatcherSupportabilityTracking() throws Excep

@Test
public void testProcessRequestMetadataDispatcherSupportabilityTracking() throws Exception {
String className = APISupportabilityTest.ProcessRequestMetadataDispatcherTestClass.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessRequestMetadata", "()V;");
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");

final String processRequestMetadataMetric = "Supportability/API/ProcessRequestMetadata/API";
new ProcessRequestMetadataDispatcherTestClass().getProcessRequestMetadata();
try {
String className = APISupportabilityTest.ProcessRequestMetadataDispatcherTestClass.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessRequestMetadata", "()V;");

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processRequestMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processRequestMetadataMetric));
final String processRequestMetadataMetric = "Supportability/API/ProcessRequestMetadata/API";
new ProcessRequestMetadataDispatcherTestClass().getProcessRequestMetadata();

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processRequestMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processRequestMetadataMetric));
} finally {
holder.close();
}
}

@Test
Expand All @@ -885,15 +904,22 @@ public void testProcessRequestMetadataNonDispatcherSupportabilityTracking() thro

@Test
public void testBridgeProcessRequestMetadataDispatcherSupportabilityTracking() throws Exception {
String className = APISupportabilityTest.ProcessRequestMetadataDispatcherBridgeTestClass.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessRequestMetadata", "()V;");
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");

final String processRequestMetadataMetric = "Supportability/API/ProcessRequestMetadata/API";
new ProcessRequestMetadataDispatcherBridgeTestClass().getProcessRequestMetadata();
try {
String className = APISupportabilityTest.ProcessRequestMetadataDispatcherBridgeTestClass.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessRequestMetadata", "()V;");

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processRequestMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processRequestMetadataMetric));
final String processRequestMetadataMetric = "Supportability/API/ProcessRequestMetadata/API";
new ProcessRequestMetadataDispatcherBridgeTestClass().getProcessRequestMetadata();

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processRequestMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processRequestMetadataMetric));
} finally {
holder.close();
}
}

@Test
Expand All @@ -912,15 +938,22 @@ public void testBridgeProcessRequestMetadataNonDispatcherSupportabilityTracking(

@Test
public void testProcessResponseMetadataDispatcherSupportabilityTracking1() throws Exception {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherTestClass1.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");

final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherTestClass1().getProcessResponseMetadata();
try {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherTestClass1.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherTestClass1().getProcessResponseMetadata();

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
} finally {
holder.close();
}
}

@Test
Expand All @@ -939,15 +972,22 @@ public void testProcessResponseMetadataNonDispatcherSupportabilityTracking1() th

@Test
public void testBridgeProcessResponseMetadataDispatcherSupportabilityTracking1() throws Exception {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherBridgeTestClass1.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");

final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherBridgeTestClass1().getProcessResponseMetadata();
try {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherBridgeTestClass1.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherBridgeTestClass1().getProcessResponseMetadata();

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
} finally {
holder.close();
}
}

@Test
Expand All @@ -966,15 +1006,22 @@ public void testBridgeProcessResponseMetadataNonDispatcherSupportabilityTracking

@Test
public void testProcessResponseMetadataDispatcherSupportabilityTracking2() throws Exception {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherTestClass2.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");

final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherTestClass2().getProcessResponseMetadata();
try {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherTestClass2.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherTestClass2().getProcessResponseMetadata();

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
} finally {
holder.close();
}
}

@Test
Expand All @@ -993,15 +1040,22 @@ public void testProcessResponseMetadataNonDispatcherSupportabilityTracking2() th

@Test
public void testBridgeProcessResponseMetadataDispatcherSupportabilityTracking2() throws Exception {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherBridgeTestClass2.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");

final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherBridgeTestClass2().getProcessResponseMetadata();
try {
String className = APISupportabilityTest.ProcessResponseMetadataDispatcherBridgeTestClass2.class.getName();
InstrumentTestUtils.createTransformerAndRetransformClass(className, "getProcessResponseMetadata", "()V;");

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
final String processResponseMetadataMetric = "Supportability/API/ProcessResponseMetadata/API";
new ProcessResponseMetadataDispatcherBridgeTestClass2().getProcessResponseMetadata();

Map<String, Integer> metricData = InstrumentTestUtils.getAndClearMetricData();
Assert.assertNotNull(metricData.get(processResponseMetadataMetric));
Assert.assertEquals(Integer.valueOf(1), metricData.get(processResponseMetadataMetric));
} finally {
holder.close();
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.newrelic.agent.environment.AgentIdentity;
import com.newrelic.agent.errors.ErrorService;
import com.newrelic.agent.errors.TracedError;
import com.newrelic.agent.instrumentation.APISupportabilityTest;
import com.newrelic.agent.metric.MetricName;
import com.newrelic.agent.service.ServiceFactory;
import com.newrelic.agent.stats.ResponseTimeStats;
Expand Down Expand Up @@ -66,6 +67,8 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import test.newrelic.EnvironmentHolderSettingsGenerator;
import test.newrelic.test.agent.EnvironmentHolder;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
Expand All @@ -89,6 +92,8 @@

public class ApiTest implements TransactionListener {
ApiTestHelper apiTestHelper = new ApiTestHelper();
private static final String CONFIG_FILE = "configs/cross_app_tracing_test.yml";
private static final ClassLoader CLASS_LOADER = ApiTest.class.getClassLoader();

@Before
public void before() {
Expand All @@ -110,6 +115,13 @@ public void after() {
ServiceFactory.getTransactionService().addTransactionListener(this);
}

public EnvironmentHolder setupEnvironmentHolder(String environment) throws Exception {
EnvironmentHolderSettingsGenerator envHolderSettings = new EnvironmentHolderSettingsGenerator(CONFIG_FILE, environment, CLASS_LOADER);
EnvironmentHolder environmentHolder = new EnvironmentHolder(envHolderSettings);
environmentHolder.setupEnvironment();
return environmentHolder;
}

@Override
public void dispatcherTransactionFinished(TransactionData transactionData, TransactionStats transactionStats) {
apiTestHelper.tranStats = transactionStats;
Expand Down Expand Up @@ -1869,7 +1881,9 @@ private void runTestExternalAPI() {
/* External/CAT - FIT to Public API */

@Test
public void testExternalCatAPI() {
public void testExternalCatAPI() throws Exception {
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");
TestServer server = new TestServer(8088);

try {
Expand All @@ -1881,6 +1895,7 @@ public void testExternalCatAPI() {
} finally {
Transaction.clearTransaction();
server.closeAllConnections();
holder.close();
}
}

Expand Down Expand Up @@ -2030,8 +2045,11 @@ public String toObfuscatedQueryString(BsonDocument query) {
/* Messaging - FIT to Public API */

@Test
public void testMessagingAPI() {
public void testMessagingAPI() throws Exception {
// override default agent config to disabled distributed tracing and use CAT instead
EnvironmentHolder holder = setupEnvironmentHolder("cat_enabled_dt_disabled_test");
MessagingTestServer server = new MessagingTestServer(8088);

try {
server.start();
runTestMessagingAPI();
Expand All @@ -2043,6 +2061,7 @@ public void testMessagingAPI() {
} finally {
Transaction.clearTransaction();
server.closeAllConnections();
holder.close();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cat_enabled_dt_enabled_test:

cross_application_tracer:
enabled: true
cross_process_id: '12345#xyz'
encoding_key: asdf
trusted_account_ids: '12345'

distributed_tracing:
enabled: true

cat_enabled_dt_disabled_test:

cross_application_tracer:
enabled: true
cross_process_id: '12345#xyz'
encoding_key: asdf
trusted_account_ids: '12345'

distributed_tracing:
enabled: false
Loading