use of com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat in project newrelic-java-agent by newrelic.
the class JsonTracer method generateRootBackgroundTracer.
private DefaultTracer generateRootBackgroundTracer(Long initTime) {
long time = getStartTime(initTime);
ClassMethodSignature sig = new ClassMethodSignature("clazz", tracerName, "()");
Object reference = new Object();
int flags = TracerFlags.DISPATCHER;
if (startTimeNs != 0) {
flags = TracerFlags.ASYNC;
}
DefaultTracer tracer = new OtherRootTracer(Transaction.getTransaction().getTransactionActivity(), sig, reference, new ClassMethodMetricNameFormat(sig, reference), flags, time);
Transaction.getTransaction().getTransactionActivity().tracerStarted(tracer);
return tracer;
}
use of com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat in project newrelic-java-agent by newrelic.
the class AbstractExceptionHandlerPointCut method doGetTracer.
@Override
public final Tracer doGetTracer(final Transaction transaction, ClassMethodSignature sig, Object errorHandler, Object[] args) {
final Throwable throwable = getThrowable(sig, args);
if (throwable == null) {
return null;
}
return new DefaultTracer(transaction, sig, errorHandler, new ClassMethodMetricNameFormat(sig, errorHandler)) {
@Override
protected void doFinish(int opcode, Object returnValue) {
// Should this be TransactionErrorPriority.TRACER?
transaction.setThrowable(throwable, TransactionErrorPriority.API, false);
super.doFinish(opcode, returnValue);
}
};
}
use of com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat in project newrelic-java-agent by newrelic.
the class CrossProcessStateCatApiTest method testCatApiResponseExternalMetrics.
@Test
public void testCatApiResponseExternalMetrics() throws UnsupportedEncodingException {
Transaction transactionOne = Mockito.mock(Transaction.class);
Mockito.when(transactionOne.getAgentConfig()).thenReturn(ServiceFactory.getConfigService().getDefaultAgentConfig());
TransactionActivity txaOne = Mockito.mock(TransactionActivity.class);
CrossProcessConfig cpsOneConfig = getCrossProcessConfig("CrossProcessId", "");
setUpTransaction(transactionOne, txaOne, new Object(), new MockDispatcher(), cpsOneConfig, "guid");
MetricNameFormat nameFormat = new ClassMethodMetricNameFormat(new ClassMethodSignature("className", "methodName", "()V"), null, "");
CatTestCustomTracer requestTracer = new CatTestCustomTracer(transactionOne, new ClassMethodSignature("className", "methodName", "()V"), new Object(), nameFormat, TracerFlags.DISPATCHER);
when(txaOne.getLastTracer()).thenReturn(requestTracer);
CrossProcessTransactionStateImpl cpsOne = CrossProcessTransactionStateImpl.create(transactionOne);
Transaction transactionTwo = Mockito.mock(Transaction.class);
Mockito.when(transactionTwo.getAgentConfig()).thenReturn(ServiceFactory.getConfigService().getDefaultAgentConfig());
TransactionActivity txaTwo = Mockito.mock(TransactionActivity.class);
CrossProcessConfig cpsTwoConfig = getCrossProcessConfig("CrossProcessId", "");
setUpTransaction(transactionTwo, txaTwo, new Object(), new MockDispatcher(), cpsTwoConfig, "guid");
InboundHeaderState ihs = Mockito.mock(InboundHeaderState.class);
when(ihs.isTrustedCatRequest()).thenReturn(true);
when(transactionTwo.getInboundHeaderState()).thenReturn(ihs);
CrossProcessTransactionStateImpl cpsTwo = CrossProcessTransactionStateImpl.create(transactionTwo);
String requestMetadata = cpsOne.getRequestMetadata();
// Transaction one generates requestMetadata. This metadata is embedded in payload and sent to transaction two.
// Transaction two gets requestMetadata from payload and provides it to agent.
cpsTwo.processRequestMetadata(requestMetadata);
String responseMetadata = cpsTwo.getResponseMetadata();
// Transaction two generates responseMetadata and sends it to transaction one.
// Transaction one receives response.
cpsOne.processResponseMetadata(responseMetadata, null);
Set<String> rollupMetricNames = requestTracer.getRollupMetricNames();
assertTrue(rollupMetricNames.contains("External/all"));
assertTrue(rollupMetricNames.contains("External/allOther"));
assertTrue(rollupMetricNames.contains("External/Unknown/all"));
}
Aggregations