Search in sources :

Example 31 with SpanEvent

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"));
}
Also used : HttpParameters(com.newrelic.api.agent.HttpParameters) SpanEvent(com.newrelic.agent.model.SpanEvent) Test(org.junit.Test)

Example 32 with SpanEvent

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());
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent) Test(org.junit.Test)

Example 33 with SpanEvent

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"));
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent) Test(org.junit.Test)

Example 34 with SpanEvent

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"));
}
Also used : SpanEvent(com.newrelic.agent.model.SpanEvent) SpanError(com.newrelic.agent.model.SpanError) Test(org.junit.Test)

Example 35 with SpanEvent

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