Search in sources :

Example 1 with W3CTraceParent

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

Example 2 with W3CTraceParent

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);
}
Also used : SpanProxy(com.newrelic.agent.tracing.SpanProxy) W3CTraceParent(com.newrelic.agent.tracing.W3CTraceParent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) MetricAggregator(com.newrelic.api.agent.MetricAggregator) DistributedTracePayloadImpl(com.newrelic.agent.tracing.DistributedTracePayloadImpl)

Aggregations

W3CTraceParent (com.newrelic.agent.tracing.W3CTraceParent)2 AttributeFilter (com.newrelic.agent.model.AttributeFilter)1 SpanEvent (com.newrelic.agent.model.SpanEvent)1 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)1 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)1 SpanProxy (com.newrelic.agent.tracing.SpanProxy)1 MetricAggregator (com.newrelic.api.agent.MetricAggregator)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1