use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class TransactionNamingTest method startWebTransaction.
private void startWebTransaction(String uri) throws Exception {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setRequestURI(uri);
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
Tracer tracer = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
tx.getTransactionActivity().tracerStarted(tracer);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class JsonTracer method generateDefaultTracer.
private DefaultTracer generateDefaultTracer(long txaStartTime) {
ClassMethodSignature sig = new ClassMethodSignature("clazz", tracerName, "()");
Object reference = new Object();
DefaultTracer tracer = new DefaultTracer(Transaction.getTransaction().getTransactionActivity(), sig, reference, new ClassMethodMetricNameFormat(sig, reference), txaStartTime + startTimeNs);
Transaction.getTransaction().getTransactionActivity().tracerStarted(tracer);
return tracer;
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class JSFTest method testPhase.
@Test
public void testPhase() {
final List<Tracer> tracers = new ArrayList<>();
final MockFacesContext mockFacesContext = new MockFacesContext();
final Phase phase = new Phase() {
@Override
public void execute(FacesContext arg0) throws FacesException {
Tracer lastTracer = Transaction.getTransaction().getTransactionActivity().getLastTracer();
tracers.add(lastTracer);
}
@Override
protected void handleAfterPhase(FacesContext arg0, ListIterator<PhaseListener> arg1, PhaseEvent arg2) {
}
@Override
protected void handleBeforePhase(FacesContext arg0, ListIterator<PhaseListener> arg1, PhaseEvent arg2) {
}
@Override
protected void queueException(FacesContext ctx, Throwable t, String booleanKey) {
super.queueException(ctx, t, booleanKey);
}
@Override
protected void queueException(FacesContext ctx, Throwable t) {
super.queueException(ctx, t);
}
@Override
public PhaseId getId() {
return PhaseId.ANY_PHASE;
}
};
new Runnable() {
@Override
@Trace(dispatcher = true)
public void run() {
phase.doPhase(mockFacesContext, new MockLifecycle(), new ArrayList<PhaseListener>().listIterator());
}
}.run();
Assert.assertEquals(1, tracers.size());
Tracer tracer = tracers.get(0);
ClassMethodSignature sig = new ClassMethodSignature(phase.getClass().getName(), "doPhase", "(Ljavax/faces/context/FacesContext;Ljavax/faces/lifecycle/Lifecycle;Ljava/util/ListIterator;)V");
Assert.assertEquals(ClassMethodMetricNameFormat.getMetricName(sig, phase, MetricNames.CUSTOM), tracer.getMetricName());
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testRendersJustW3CWhenNewRelicHeaderExcluded.
@Test
public void testRendersJustW3CWhenNewRelicHeaderExcluded() {
CrossProcessTransactionStateImpl crossProcessTransactionState = setupTestForDistributedTracing(false);
OutboundHeadersMap headers = new OutboundHeadersMap(HeaderType.HTTP);
crossProcessTransactionState.populateRequestMetadata(headers, new OtherRootTracer(ta, new ClassMethodSignature("my.class", "methodname", "something"), "object", null));
assertFalse(headers.containsKey("newrelic"));
assertTrue(headers.containsKey("traceparent"));
assertTrue(headers.get("traceparent").length() > 0);
assertTrue(headers.containsKey("tracestate"));
assertTrue(headers.get("tracestate").length() > 0);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testRendersBothHeaders.
@Test
public void testRendersBothHeaders() {
CrossProcessTransactionStateImpl crossProcessTransactionState = setupTestForDistributedTracing(true);
OutboundHeadersMap headers = new OutboundHeadersMap(HeaderType.HTTP);
crossProcessTransactionState.populateRequestMetadata(headers, new OtherRootTracer(ta, new ClassMethodSignature("my.class", "methodname", "something"), "object", null));
assertTrue(headers.containsKey("newrelic"));
assertTrue(headers.get("newrelic").length() > 0);
assertTrue(headers.containsKey("traceparent"));
assertTrue(headers.get("traceparent").length() > 0);
assertTrue(headers.containsKey("tracestate"));
assertTrue(headers.get("tracestate").length() > 0);
}
Aggregations