Search in sources :

Example 26 with SpanEvent

use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.

the class DistributedSamplingPriorityQueueTest method assertPriorityExternalEvents.

private void assertPriorityExternalEvents(List<SpanEvent> spanEvents) {
    // Should be sorted by priority and then sorted by type (external at top)
    SpanEvent event = Iterables.get(spanEvents, 0);
    assertNotNull(event);
    assertEquals("7", event.getGuid());
    assertEquals(SpanCategory.http, event.getCategory());
    assertEquals(5.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 1);
    assertNotNull(event);
    assertEquals("4", event.getGuid());
    assertEquals(SpanCategory.datastore, event.getCategory());
    assertEquals(5.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 2);
    assertNotNull(event);
    assertEquals("1", event.getGuid());
    assertEquals(SpanCategory.generic, event.getCategory());
    assertEquals(5.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 3);
    assertNotNull(event);
    assertEquals("8", event.getGuid());
    assertEquals(SpanCategory.http, event.getCategory());
    assertEquals(3.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 4);
    assertNotNull(event);
    assertEquals("5", event.getGuid());
    assertEquals(SpanCategory.datastore, event.getCategory());
    assertEquals(3.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 5);
    assertNotNull(event);
    assertEquals("2", event.getGuid());
    assertEquals(SpanCategory.generic, event.getCategory());
    assertEquals(3.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 6);
    assertNotNull(event);
    assertEquals("9", event.getGuid());
    assertEquals(SpanCategory.http, event.getCategory());
    assertEquals(1.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 7);
    assertNotNull(event);
    assertEquals("6", event.getGuid());
    assertEquals(SpanCategory.datastore, event.getCategory());
    assertEquals(1.0f, event.getPriority(), 0.0f);
    event = Iterables.get(spanEvents, 8);
    assertNotNull(event);
    assertEquals("3", event.getGuid());
    assertEquals(SpanCategory.generic, event.getCategory());
    assertEquals(1.0f, event.getPriority(), 0.0f);
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent)

Example 27 with SpanEvent

use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.

the class SpanEventFactoryTest method appNameShouldBeSet.

@Test
public void appNameShouldBeSet() {
    SpanEvent target = spanEventFactory.build();
    assertEquals("green", target.getAppName());
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent) Test(org.junit.Test)

Example 28 with SpanEvent

use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.

the class SpanEventFactoryTest method shouldFilterUserAttributes.

@Test
public void shouldFilterUserAttributes() {
    SpanEventFactory target = new SpanEventFactory("blerb", new AttributeFilter.PassEverythingAttributeFilter() {

        @Override
        public Map<String, ?> filterUserAttributes(String appName, Map<String, ?> userAttributes) {
            return Collections.<String, Object>singletonMap("filtered", "yes");
        }
    }, DEFAULT_SYSTEM_TIMESTAMP_SUPPLIER);
    SpanEvent spanEvent = target.setUserAttributes(Collections.<String, Object>singletonMap("original", "sad")).build();
    assertEquals("yes", spanEvent.getUserAttributesCopy().get("filtered"));
    assertNull(spanEvent.getUserAttributesCopy().get("original"));
}
Also used : AttributeFilter(com.newrelic.agent.model.AttributeFilter) SpanEvent(com.newrelic.agent.model.SpanEvent) Map(java.util.Map) Test(org.junit.Test)

Example 29 with SpanEvent

use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.

the class SpanEventFactoryTest method shouldNotSetSpanErrorWhenFiltered.

@Test
public void shouldNotSetSpanErrorWhenFiltered() {
    SpanError spanError = new SpanError();
    spanError.setErrorClass(RuntimeException.class);
    spanError.setErrorStatus(500);
    spanError.setErrorMessage("not again");
    SpanEventFactory target = new SpanEventFactory("blerb", new PassNothingAttributeFilter(), DEFAULT_SYSTEM_TIMESTAMP_SUPPLIER);
    SpanEvent spanEvent = target.setSpanError(spanError).build();
    assertEquals(0, spanEvent.getAgentAttributes().size());
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent) SpanError(com.newrelic.agent.model.SpanError) Test(org.junit.Test)

Example 30 with SpanEvent

use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.

the class SpanEventFactoryTest method shouldNotSetNullStatusCode.

@Test
public void shouldNotSetNullStatusCode() {
    SpanEvent spanEvent = spanEventFactory.setHttpStatusCode(null).build();
    assertFalse(spanEvent.getAgentAttributes().containsKey("http.statusCode"));
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent) Test(org.junit.Test)

Aggregations

SpanEvent (com.newrelic.agent.model.SpanEvent)81 Test (org.junit.Test)64 AttributeFilter (com.newrelic.agent.model.AttributeFilter)23 SpanEventsService (com.newrelic.agent.service.analytics.SpanEventsService)19 TransactionStats (com.newrelic.agent.stats.TransactionStats)14 TransactionData (com.newrelic.agent.TransactionData)12 SpanEventsServiceImpl (com.newrelic.agent.service.analytics.SpanEventsServiceImpl)12 Tracer (com.newrelic.agent.tracers.Tracer)9 HashMap (java.util.HashMap)8 Map (java.util.Map)5 TransactionEvent (com.newrelic.agent.service.analytics.TransactionEvent)4 TransactionDataList (com.newrelic.agent.TransactionDataList)3 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)3 Test (org.junit.jupiter.api.Test)3 SpanConverterTest.buildSpanEvent (com.newrelic.SpanConverterTest.buildSpanEvent)2 BoundTransactionApiImpl (com.newrelic.agent.BoundTransactionApiImpl)2 AttributesService (com.newrelic.agent.attributes.AttributesService)2 AgentConfig (com.newrelic.agent.config.AgentConfig)2 ReservoirManager (com.newrelic.agent.interfaces.ReservoirManager)2 Consumer (com.newrelic.agent.interfaces.backport.Consumer)2