use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class SpanEventFactoryTest method shouldSetHttpParameters.
@Test
public void shouldSetHttpParameters() {
HttpParameters mockParameters = mock(HttpParameters.class);
when(mockParameters.getLibrary()).thenReturn("library");
when(mockParameters.getProcedure()).thenReturn("procedure");
SpanEvent target = spanEventFactory.setExternalParameterAttributes(mockParameters).build();
assertEquals("library", target.getIntrinsics().get("component"));
assertEquals("procedure", target.getAgentAttributes().get("http.method"));
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class SpanEventFactoryTest method shouldTruncate3KDBStatementTo2K.
@Test
public void shouldTruncate3KDBStatementTo2K() {
char[] data = new char[3000];
String threeKStatement = new String(data);
SpanEvent target = spanEventFactory.setDatabaseStatement(threeKStatement).build();
assertEquals(2000, target.getIntrinsics().get("db.statement").toString().length());
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class SpanEventFactoryTest method shouldNotSetStatusTextWhenFiltering.
@Test
public void shouldNotSetStatusTextWhenFiltering() {
SpanEventFactory factory = new SpanEventFactory("blerb", new PassNothingAttributeFilter(), DEFAULT_SYSTEM_TIMESTAMP_SUPPLIER);
SpanEvent spanEvent = factory.setHttpStatusText("I'm a teapot.").build();
assertNull(spanEvent.getAgentAttributes().get("http.statusText"));
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class SpanEventFactoryTest method shouldSetSpanErrorWithOnlyErrorClassAndMessage.
@Test
public void shouldSetSpanErrorWithOnlyErrorClassAndMessage() {
SpanError spanError = new SpanError();
spanError.setErrorClass(RuntimeException.class);
spanError.setErrorStatus(500);
spanError.setErrorMessage("not again");
SpanEvent target = spanEventFactory.setSpanError(spanError).build();
assertEquals(RuntimeException.class.getName(), target.getAgentAttributes().get("error.class"));
assertEquals(null, target.getAgentAttributes().get("error.status"));
assertEquals("not again", target.getAgentAttributes().get("error.message"));
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class SpanEventFactoryTest method shouldNotSetNullStatusText.
@Test
public void shouldNotSetNullStatusText() {
SpanEvent spanEvent = spanEventFactory.setHttpStatusText(null).build();
assertFalse(spanEvent.getAgentAttributes().containsKey("http.statusText"));
}
Aggregations