use of com.newrelic.api.agent.TransportType in project newrelic-java-agent by newrelic.
the class InboundHeaderState method parseDistributedTraceHeaders.
private void parseDistributedTraceHeaders() {
// Don't override TransportType if it has already been set
if (TransportType.Unknown.equals(tx.getTransportType())) {
TransportType transportType = inboundHeaders.getHeaderType() == HeaderType.MESSAGE ? TransportType.JMS : TransportType.HTTP;
tx.setTransportType(transportType);
}
parseAndAcceptDistributedTraceHeaders(tx, inboundHeaders);
}
use of com.newrelic.api.agent.TransportType in project newrelic-java-agent by newrelic.
the class TransactionTest method testWithNullPriorityDoesNotResetPriority.
@Test
public void testWithNullPriorityDoesNotResetPriority() throws Exception {
Map<String, Object> configMap = createConfigMap();
configMap.put(AgentConfigImpl.DISTRIBUTED_TRACING, ImmutableMap.of("enabled", Boolean.TRUE));
createServiceManager(configMap);
serviceManager.setDistributedTraceService(new DistributedTraceService() {
@Override
public boolean isEnabled() {
return true;
}
@Override
public int getMajorSupportedCatVersion() {
return 1;
}
@Override
public int getMinorSupportedCatVersion() {
return 0;
}
@Override
public String getAccountId() {
return "9123";
}
@Override
public String getApplicationId() {
return "1234";
}
@Override
public <T extends PriorityAware> float calculatePriority(Float priority, SamplingPriorityQueue<T> reservoir) {
return 0.678f;
}
@Override
public Map<String, Object> getIntrinsics(DistributedTracePayloadImpl inboundPayload, String guid, String traceId, TransportType transportType, long parentTransportDuration, long largestTransportDuration, String parentId, String parentSpanId, float priority) {
return null;
}
@Override
public String getTrustKey() {
return "67890";
}
@Override
public DistributedTracePayload createDistributedTracePayload(Tracer tracer) {
return null;
}
});
Transaction.clearTransaction();
Tracer dispatcherTracer = createDispatcherTracer(true);
Transaction transaction = dispatcherTracer.getTransactionActivity().getTransaction();
transaction.getTransactionActivity().tracerStarted(dispatcherTracer);
String inboundPayload = "{" + " \"v\": [0,2]," + " \"d\": {" + " \"ty\": \"Mobile\"," + " \"ac\": \"9123\"," + " \"tk\": \"67890\"," + " \"ap\": \"51424\"" + " \"id\": \"27856f70d3d314b7\"," + " \"tr\": \"3221bf09aa0bcf0d\"," + " \"pr\": null," + " \"ti\": 1482959525577" + " }" + "}";
transaction.acceptDistributedTracePayload(inboundPayload);
String spanId = "meatball101";
DistributedTracePayloadImpl payload = transaction.createDistributedTracePayload(spanId);
DistributedTracePayloadImpl secondPayload = transaction.createDistributedTracePayload(spanId);
dispatcherTracer.finish(Opcodes.ARETURN, null);
// Verify that when the inbound priority is null, that we retain our priority.
assertEquals("Mobile", transaction.getSpanProxy().getInboundDistributedTracePayload().parentType);
assertEquals(0.678f, payload.priority, 0.0f);
// Verify that the payload that gets passed on will preserve the priority we created.
assertEquals("App", secondPayload.parentType);
assertEquals("3221bf09aa0bcf0d", secondPayload.traceId);
assertEquals(spanId, secondPayload.guid);
assertEquals(0.678f, secondPayload.priority, 0.0f);
}
Aggregations