use of com.newrelic.agent.service.analytics.TransactionEventBuilder in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImplTest method testPriorityIsUsed.
@Test
public void testPriorityIsUsed() {
rpmServiceManager.getOrCreateRPMService("Test");
// Create reservoir
ServiceFactory.getTransactionEventsService().harvestEvents("Test");
DistributedSamplingPriorityQueue<TransactionEvent> reservoir = new DistributedSamplingPriorityQueue<>(3);
TransactionEventBuilder eventBuilder = new TransactionEventBuilder();
eventBuilder.setPriority(.5f);
TransactionEvent transactionEvent5 = eventBuilder.build();
reservoir.add(transactionEvent5);
eventBuilder.setPriority(.6f);
TransactionEvent transactionEvent6 = eventBuilder.build();
reservoir.add(transactionEvent6);
eventBuilder.setPriority(.7f);
TransactionEvent transactionEvent7 = eventBuilder.build();
reservoir.add(transactionEvent7);
eventBuilder.setPriority(.8f);
TransactionEvent transactionEvent8 = eventBuilder.build();
reservoir.add(transactionEvent8);
eventBuilder.setPriority(.9f);
TransactionEvent transactionEvent9 = eventBuilder.build();
reservoir.add(transactionEvent9);
List<TransactionEvent> events = reservoir.asList();
assertTrue(events.contains(transactionEvent7));
assertTrue(events.contains(transactionEvent8));
assertTrue(events.contains(transactionEvent9));
assertEquals(3, events.size());
eventBuilder.setPriority(.4f);
TransactionEvent transactionEvent4 = eventBuilder.build();
reservoir.add(transactionEvent4);
eventBuilder.setPriority(.3f);
TransactionEvent transactionEvent3 = eventBuilder.build();
reservoir.add(transactionEvent3);
events = reservoir.asList();
assertTrue(events.contains(transactionEvent7));
assertTrue(events.contains(transactionEvent8));
assertTrue(events.contains(transactionEvent9));
assertEquals(3, events.size());
}
Aggregations