use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method testTracerAttributes.
@Test
public void testTracerAttributes() {
// setup
tracerUserAttributes.put("user", "attribute");
expectedUserAttributes.put("user", "attribute");
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
TracerToSpanEvent testClass = new TracerToSpanEvent(errorBuilderMap, new AttributeFilter.PassEverythingAttributeFilter(), timestampProvider, environmentService, transactionDataToDistributedTraceIntrinsics, spanErrorBuilder);
// execution
SpanEvent spanEvent = testClass.createSpanEvent(tracer, txnData, txnStats, true, false);
// assertions
assertEquals(expectedSpanEvent, spanEvent);
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method testParentIdFromW3CPayload.
@Test
public void testParentIdFromW3CPayload() {
// setup
String parentGuid = "98765";
expectedIntrinsicAttributes.put("parentId", parentGuid);
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
W3CTraceParent w3cPayload = mock(W3CTraceParent.class);
when(txnData.getW3CTraceParent()).thenReturn(w3cPayload);
when(w3cPayload.getParentId()).thenReturn(parentGuid);
TracerToSpanEvent testClass = new TracerToSpanEvent(errorBuilderMap, new AttributeFilter.PassEverythingAttributeFilter(), timestampProvider, environmentService, transactionDataToDistributedTraceIntrinsics, spanErrorBuilder);
// execution
SpanEvent spanEvent = testClass.createSpanEvent(tracer, txnData, txnStats, isRoot, false);
// assertions
assertEquals(expectedSpanEvent, spanEvent);
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method testGraphQLAttribute.
@Test
public void testGraphQLAttribute() {
// setup
expectedAgentAttributes.put("graphql.operation.type", "Query");
expectedAgentAttributes.put("graphql.field.name", "book");
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
tracerAgentAttributes.put("graphql.operation.type", "Query");
tracerAgentAttributes.put("graphql.field.name", "book");
TracerToSpanEvent testClass = new TracerToSpanEvent(errorBuilderMap, new AttributeFilter.PassEverythingAttributeFilter(), timestampProvider, environmentService, transactionDataToDistributedTraceIntrinsics, spanErrorBuilder);
// execution
SpanEvent spanEvent = testClass.createSpanEvent(tracer, txnData, txnStats, true, false);
when(txnData.getAgentAttributes()).thenReturn(transactionAgentAttributes);
// assertions
assertEquals(expectedSpanEvent, spanEvent);
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method testUndesiredAttributesFiltered.
@Test
public void testUndesiredAttributesFiltered() {
// setup
Map<String, Object> intrinsicAttributes = new HashMap<>();
intrinsicAttributes.put("foo", "bar");
intrinsicAttributes.put("externalCallCount", 13);
Map<String, Object> userAttributes = new HashMap<>();
userAttributes.put("ok", "okey");
userAttributes.put("host.displayName", "myrad.server");
userAttributes.put("parentSpanId", "1234-abcd");
transactionAgentAttributes.put("a", "b");
transactionAgentAttributes.put("nr.guid", "I sure hope I don't make it to the output");
expectedAgentAttributes.put("a", "b");
expectedAgentAttributes.put("foo", "bar");
expectedUserAttributes = new HashMap<>();
expectedUserAttributes.put("ok", "okey");
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
when(txnData.getIntrinsicAttributes()).thenReturn(intrinsicAttributes);
when(txnData.getUserAttributes()).thenReturn(userAttributes);
when(txnData.getAgentAttributes()).thenReturn(transactionAgentAttributes);
TracerToSpanEvent testClass = new TracerToSpanEvent(errorBuilderMap, new AttributeFilter.PassEverythingAttributeFilter(), timestampProvider, environmentService, transactionDataToDistributedTraceIntrinsics, spanErrorBuilder);
// execution
SpanEvent spanEvent = testClass.createSpanEvent(tracer, txnData, txnStats, true, false);
// assertions
assertEquals(expectedSpanEvent, spanEvent);
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method testAutoAppNaming.
@Test
public void testAutoAppNaming() {
// setup
String newAppName = "new app name";
when(txnData.getApplicationName()).thenReturn(newAppName);
SpanEvent expectedSpanEvent = SpanEvent.builder().appName(newAppName).priority(priority).putAllAgentAttributes(expectedAgentAttributes).putAllIntrinsics(expectedIntrinsicAttributes).putAllUserAttributes(expectedUserAttributes).decider(true).timestamp(timestamp).build();
when(spanErrorBuilder.areErrorsEnabled()).thenReturn(true);
TracerToSpanEvent testClass = new TracerToSpanEvent(errorBuilderMap, new AttributeFilter.PassEverythingAttributeFilter(), timestampProvider, environmentService, transactionDataToDistributedTraceIntrinsics, spanErrorBuilder);
// execution
SpanEvent spanEvent = testClass.createSpanEvent(tracer, txnData, txnStats, true, false);
// assertions
assertEquals(expectedSpanEvent, spanEvent);
}
Aggregations