use of com.newrelic.agent.tracing.W3CTraceParent 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.tracing.W3CTraceParent in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method setupTestForDistributedTracing.
private CrossProcessTransactionStateImpl setupTestForDistributedTracing(boolean includeNewRelicHeader) {
String encodingKey = "test";
String txGuid = "ee8e5ef1a374c0ec";
DistributedTracePayloadImpl payload = DistributedTracePayloadImpl.createDistributedTracePayload("14", "15", txGuid, 1.678f);
when(crossProcessConfig.isCrossApplicationTracing()).thenReturn(true);
when(crossProcessConfig.getEncodingKey()).thenReturn(encodingKey);
when(distributedTracingConfig.isEnabled()).thenReturn(true);
when(distributedTracingConfig.isIncludeNewRelicHeader()).thenReturn(includeNewRelicHeader);
when(spanEventsConfig.isEnabled()).thenReturn(true);
when(transactionEventsConfig.isEnabled()).thenReturn(true);
when(tx.getPriorityTransactionName()).thenReturn(PriorityTransactionName.create("Test", "TEST", TransactionNamePriority.NONE));
when(tx.getApplicationName()).thenReturn("TestApp");
when(tx.getGuid()).thenReturn(txGuid);
when(tx.createDistributedTracePayload(anyString())).thenReturn(payload);
mockConfigFromTransaction();
InboundHeaderState ihs = mock(InboundHeaderState.class);
SpanProxy spanProxy = mock(SpanProxy.class);
when(tx.getInboundHeaderState()).thenReturn(ihs);
when(tx.sampled()).thenReturn(true);
when(tx.getMetricAggregator()).thenReturn(mock(MetricAggregator.class));
when(tx.getSpanProxy()).thenReturn(spanProxy);
W3CTraceParent traceParent = new W3CTraceParent("1.0", "traceId123abc", "parentId987", 11);
when(spanProxy.getInitiatingW3CTraceParent()).thenReturn(traceParent);
when(spanProxy.getOutboundDistributedTracePayload()).thenReturn(payload);
TransactionTraceService transactionTraceService = mock(TransactionTraceService.class);
serviceManager.setTransactionTraceService(transactionTraceService);
return CrossProcessTransactionStateImpl.create(tx);
}
Aggregations