Search in sources :

Example 1 with TransactionEventBuilder

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());
}
Also used : TransactionEvent(com.newrelic.agent.service.analytics.TransactionEvent) DistributedSamplingPriorityQueue(com.newrelic.agent.service.analytics.DistributedSamplingPriorityQueue) TransactionEventBuilder(com.newrelic.agent.service.analytics.TransactionEventBuilder) Test(org.junit.Test)

Aggregations

DistributedSamplingPriorityQueue (com.newrelic.agent.service.analytics.DistributedSamplingPriorityQueue)1 TransactionEvent (com.newrelic.agent.service.analytics.TransactionEvent)1 TransactionEventBuilder (com.newrelic.agent.service.analytics.TransactionEventBuilder)1 Test (org.junit.Test)1