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);
}
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());
}
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"));
}
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());
}
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"));
}
Aggregations