use of com.newrelic.agent.DistributedTracePayloadBuilder in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImplTest method txnFinishedInboundPayload.
@Test
public void txnFinishedInboundPayload() {
Map<String, Object> connectInfo = new HashMap<>();
connectInfo.put(DistributedTracingConfig.ACCOUNT_ID, "1acct234");
connectInfo.put(DistributedTracingConfig.TRUSTED_ACCOUNT_KEY, "67890");
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
distributedTraceService.connected(null, agentConfig);
TransactionStats transactionStats = new TransactionStats();
Map<String, Object> intrinsicAttributes = new HashMap<>();
long payloadSendTimestamp = 1002000;
long startTimeInMillis = 1005000;
long responseTimeInNanos = TimeUnit.MILLISECONDS.toNanos(1350);
String json = new DistributedTracePayloadBuilder().setTimestamp(payloadSendTimestamp).setHost("datanerd.us.com").setParentType("Browser").setAccountId("123456").setTrustKey("67890").setApplicationId("6789").setTransactionId("badcafe3").setTripId("cattrip").setPriority(0.0f).setDepth(0).setSyntheticsJob(null).setSyntheticsMonitor(null).setSyntheticsResource(null).createJsonPayload();
DistributedTracePayloadImpl payload = new DistributedTracePayloadParser(NewRelic.getAgent().getMetricAggregator(), distributedTraceService, Agent.LOG).parse(null, json);
TransactionData transactionData = createTransactionData(intrinsicAttributes, startTimeInMillis, responseTimeInNanos, payload);
distributedTraceService.dispatcherTransactionFinished(transactionData, transactionStats);
SimpleStatsEngine unscopedStats = transactionStats.getUnscopedStats();
assertEquals(1.35f, unscopedStats.getOrCreateResponseTimeStats("DurationByCaller/Browser/123456/6789/HTTPS/all").getTotal(), 0.01f);
assertEquals(3.0f, unscopedStats.getOrCreateResponseTimeStats("TransportDuration/Browser/123456/6789/HTTPS/all").getTotal(), 0.01f);
}
Aggregations