use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method testWithTraceState.
@Test
public void testWithTraceState() {
// setup
String guid = "1234-abcd-dead-beef";
expectedIntrinsicAttributes.put("trustedParentId", guid);
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
W3CTraceState traceState = mock(W3CTraceState.class);
when(traceState.getGuid()).thenReturn(guid);
when(spanProxy.getInitiatingW3CTraceState()).thenReturn(traceState);
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 testParentIdFromDTPayload.
@Test
public void testParentIdFromDTPayload() {
// setup
String parentGuid = "98765";
expectedIntrinsicAttributes.put("parentId", parentGuid);
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
DistributedTracePayloadImpl dtPayload = mock(DistributedTracePayloadImpl.class);
when(dtPayload.getGuid()).thenReturn(parentGuid);
when(txnData.getInboundDistributedTracePayload()).thenReturn(dtPayload);
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 testPrefixedAttributesAddedToRoot.
@Test
public void testPrefixedAttributesAddedToRoot() {
Map<String, Map<String, String>> prefixedAttributes = new HashMap<>();
Map<String, String> requestAttributes = new HashMap<>();
Map<String, String> messagingAttributes = new HashMap<>();
prefixedAttributes.put(HTTP_REQUEST_PREFIX, requestAttributes);
prefixedAttributes.put(MESSAGE_REQUEST_PREFIX, messagingAttributes);
requestAttributes.put("count", "7");
messagingAttributes.put("messagingService", "fakebook");
// setup
expectedAgentAttributes.put(HTTP_REQUEST_PREFIX + "count", "7");
expectedAgentAttributes.put(MESSAGE_REQUEST_PREFIX + "messagingService", "fakebook");
SpanEvent expectedSpanEvent = buildExpectedSpanEvent();
when(txnData.getPrefixedAttributes()).thenReturn(prefixedAttributes);
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 SpanEventFactoryTest method categoryShouldBeSet.
@Test
public void categoryShouldBeSet() {
SpanEvent target = spanEventFactory.setCategory(SpanCategory.http).build();
assertEquals(SpanCategory.http, target.getCategory());
}
use of com.newrelic.agent.model.SpanEvent in project newrelic-java-agent by newrelic.
the class SpanEventFactoryTest method shouldNotSetStatusCodeWhenFiltering.
@Test
public void shouldNotSetStatusCodeWhenFiltering() {
SpanEventFactory factory = new SpanEventFactory("blerb", new PassNothingAttributeFilter(), DEFAULT_SYSTEM_TIMESTAMP_SUPPLIER);
SpanEvent spanEvent = factory.setHttpStatusCode(418).build();
assertNull(spanEvent.getAgentAttributes().get("http.statusCode"));
}
Aggregations