use of com.newrelic.agent.tracers.metricname.MetricNameFormat in project newrelic-java-agent by newrelic.
the class TransactionNamingTest method startOtherTransaction.
private void startOtherTransaction(String uri) throws Exception {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("", "", "");
MetricNameFormat format = new SimpleMetricNameFormat(uri);
Tracer tracer = new OtherRootTracer(tx, sig, this, format);
tx.getTransactionActivity().tracerStarted(tracer);
}
use of com.newrelic.agent.tracers.metricname.MetricNameFormat in project newrelic-java-agent by newrelic.
the class AbstractPriorityTransactionNamingPolicyTest method startOtherTransaction.
private void startOtherTransaction() throws Exception {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("", "", "");
MetricNameFormat format = new SimpleMetricNameFormat("");
Tracer tracer = new OtherRootTracer(tx, sig, this, format);
tx.getTransactionActivity().tracerStarted(tracer);
}
use of com.newrelic.agent.tracers.metricname.MetricNameFormat in project newrelic-java-agent by newrelic.
the class MetricNameFormatsTest method testFormatterCustom.
// @formatter:on
@Test
public void testFormatterCustom() {
MetricNameFormat mnf;
for (int i = 0; i < testCases.length; i += 2) {
Args args = (Args) testCases[i];
Expected expected = (Expected) testCases[i + 1];
mnf = get(args);
Assert.assertTrue("tried: " + args + "; expected: " + expected + "; got: " + mnfToString(mnf), chk(mnf, expected));
}
}
use of com.newrelic.agent.tracers.metricname.MetricNameFormat in project newrelic-java-agent by newrelic.
the class TransactionStateImpl method getSqlTracer.
@Override
public Tracer getSqlTracer(Transaction tx, Object invocationTarget, ClassMethodSignature sig, String metricName, int flags) {
TransactionActivity activity = tx.getTransactionActivity();
if (tx.isIgnore() || activity.isTracerStartLocked()) {
return null;
}
if (currentlyExceedingSegmentLimit(tx, sig)) {
return UltraLightTracer.createClampedSegment(activity, sig);
}
Tracer tracer;
final MetricNameFormat mnf = MetricNameFormats.getFormatter(invocationTarget, sig, metricName, flags);
if (TracerFlags.isDispatcher(flags)) {
tracer = new OtherRootSqlTracer(tx, sig, invocationTarget, mnf);
} else {
tracer = new DefaultSqlTracer(tx, sig, invocationTarget, mnf, flags);
}
return tracerStarted(tx, sig, tracer);
}
use of com.newrelic.agent.tracers.metricname.MetricNameFormat in project newrelic-java-agent by newrelic.
the class InstrumentationImpl method oldCreateTracer.
// This code path is similar to the 3.16.1 and earlier tracer creation path. It is retained for use by legacy async
// instrumentation: Play1 and async servlet 3.0 instrumentation. The key difference from the "fast path" is that
// this path switches on the TransactionState during creation.
private ExitTracer oldCreateTracer(TransactionActivity txa, Object invocationTarget, int signatureId, String metricName, int flags) {
// oldCreateTracer behavior below.
if (txa == null) {
AgentBridge.TokenAndRefCount tokenAndRefCount = AgentBridge.activeToken.get();
if (tokenAndRefCount != null && tokenAndRefCount.token != null) {
// Fast path for scala instrumentation (and potentially others in the future)
Transaction tx = Transaction.getTransaction(false);
if (tx == null) {
if (tokenAndRefCount.token.getTransaction() instanceof Transaction) {
tx = (Transaction) tokenAndRefCount.token.getTransaction();
} else {
return null;
}
}
txa = TransactionActivity.create(tx, Integer.MAX_VALUE);
flags = flags | TracerFlags.ASYNC;
ClassMethodSignature sig = ClassMethodSignatures.get().get(signatureId);
MetricNameFormat mnf = MetricNameFormats.getFormatter(invocationTarget, sig, metricName, flags);
Tracer tracer;
if (TracerFlags.isRoot(flags)) {
// Dispatcher || Async
tracer = new OtherRootTracer(txa, sig, invocationTarget, mnf, flags);
} else {
tracer = new DefaultTracer(txa, sig, invocationTarget, mnf, flags);
}
txa.tracerStarted(tracer);
Tracer initiatingTracer = (Tracer) tokenAndRefCount.tracedMethod.getAndSet(tracer);
tx.startFastAsyncWork(txa, initiatingTracer);
return noticeTracer(signatureId, flags, tracer);
} else if (TracerFlags.isAsync(flags)) {
txa = TransactionActivity.create(null, Integer.MAX_VALUE);
return startTracer(txa, invocationTarget, signatureId, metricName, flags);
}
}
// Avoid creating tracers for NoOpTransaction, etc.
com.newrelic.agent.Transaction transaction = com.newrelic.agent.Transaction.getTransaction(TracerFlags.isDispatcher(flags));
if (transaction == null) {
return null;
}
try {
if (!TracerFlags.isDispatcher(flags) && !transaction.isStarted()) {
// if we're not in a transaction and this isn't a dispatcher tracer, bail before we create objects
return noticeTracer(signatureId, flags, null);
}
if (transaction.getTransactionActivity().isLeaf()) {
return null;
}
ClassMethodSignature sig = ClassMethodSignatures.get().get(signatureId);
return transaction.getTransactionState().getTracer(transaction, invocationTarget, sig, metricName, flags);
} catch (Throwable t) {
logger.log(Level.FINEST, t, "createTracer({0}, {1}, {2}, {3})", invocationTarget, signatureId, metricName, flags);
return null;
}
}
Aggregations