Search in sources :

Example 6 with Tracer

use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.

the class TransactionStateImpl method getTracer.

/**
 * Get tracer for weaved code and XML instrumentation (no tracer factory)
 */
@Override
public Tracer getTracer(Transaction tx, final Object invocationTarget, final ClassMethodSignature sig, final String metricName, final int flags) {
    TransactionActivity activity = tx.getTransactionActivity();
    if (tx.isIgnore() || activity.isTracerStartLocked()) {
        return null;
    }
    Tracer tracer;
    final MetricNameFormat mnf = MetricNameFormats.getFormatter(invocationTarget, sig, metricName, flags);
    if (TracerFlags.isDispatcher(flags)) {
        tracer = new OtherRootTracer(tx, sig, invocationTarget, mnf);
    } else {
        tracer = new DefaultTracer(tx, sig, invocationTarget, mnf, flags);
    }
    return tracerStarted(tx, sig, tracer);
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) OtherRootSqlTracer(com.newrelic.agent.tracers.OtherRootSqlTracer) UltraLightTracer(com.newrelic.agent.tracers.UltraLightTracer) DefaultSqlTracer(com.newrelic.agent.tracers.DefaultSqlTracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) SkipTracer(com.newrelic.agent.tracers.SkipTracer) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 7 with Tracer

use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.

the class AgentImpl method getTracedMethod.

/**
 * If in a transaction, then getTransaction().getTracedMethod() returns the same thing as this method. If outside a
 * transaction then this method returns a noop. Note: The getTransaction().getTracedMethod() will return null.
 */
@Override
public TracedMethod getTracedMethod() {
    com.newrelic.agent.bridge.Transaction transaction = getTransaction(false);
    if (NoOpTransaction.INSTANCE.equals(transaction)) {
        return NoOpTracedMethod.INSTANCE;
    }
    com.newrelic.agent.Transaction txn = com.newrelic.agent.Transaction.getTransaction(false);
    // TransactionApiImpl to ensure the same behavior.
    if (txn == null) {
        return NoOpTracedMethod.INSTANCE;
    }
    TransactionActivity txa = txn.getTransactionActivity();
    if (txa == null) {
        return NoOpTracedMethod.INSTANCE;
    }
    Tracer tracer = txa.getLastTracer();
    return (tracer == null) ? NoOpTracedMethod.INSTANCE : tracer;
}
Also used : Tracer(com.newrelic.agent.tracers.Tracer) Transaction(com.newrelic.agent.bridge.Transaction)

Example 8 with Tracer

use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.

the class Segment method ignoreIfUnfinished.

/**
 * {@inheritDoc}
 */
@Override
public void ignoreIfUnfinished() {
    if (!isFinished.getAndSet(true)) {
        Tracer tracer = parent;
        if (tracer != null) {
            tracer.getTransactionActivity().getTransaction().ignoreSegmentIfUnfinished(this);
        }
        // Remove references to underlying and parent tracer to prevent GC issues
        underlyingTracer = null;
        parent = null;
        weakRefTransaction = null;
    }
}
Also used : Tracer(com.newrelic.agent.tracers.Tracer)

Example 9 with Tracer

use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.

the class Segment method finish.

private void finish(final Throwable t, boolean async) {
    if (!isFinished.getAndSet(true)) {
        markFinishTime();
        final Tracer tracer = parent;
        final Segment segment = this;
        final String endThreadName = Thread.currentThread().getName();
        if (tracer != null) {
            Runnable expireSegmentRunnable = new Runnable() {

                @Override
                public void run() {
                    tracer.getTransactionActivity().getTransaction().finishSegment(segment, t, parent, endThreadName);
                    // Remove references to underlying and parent tracer to prevent GC issues
                    underlyingTracer = null;
                    parent = null;
                    weakRefTransaction = null;
                }
            };
            if (async) {
                ServiceFactory.getExpirationService().expireSegment(expireSegmentRunnable);
            } else {
                ServiceFactory.getExpirationService().expireSegmentInline(expireSegmentRunnable);
            }
        }
    }
}
Also used : Tracer(com.newrelic.agent.tracers.Tracer)

Example 10 with Tracer

use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.

the class TokenImpl method setTruncated.

void setTruncated() {
    final Tracer tracer = initiatingTracer;
    if (tracer != null) {
        tracer.setMetricNameFormatInfo(tracer.getMetricName(), "Truncated/" + tracer.getMetricName(), tracer.getTransactionSegmentUri());
        String timeoutCauseMetric = MessageFormat.format(MetricNames.SUPPORTABILITY_ASYNC_TOKEN_TIMEOUT_CAUSE, tracer.getClassMethodSignature());
        ServiceFactory.getStatsService().doStatsWork(StatsWorks.getIncrementCounterWork(timeoutCauseMetric, 1), timeoutCauseMetric);
    } else {
        Agent.LOG.log(Level.FINEST, "Initiating tracer is null. Unable to mark segment as truncated.");
    }
}
Also used : Tracer(com.newrelic.agent.tracers.Tracer)

Aggregations

Tracer (com.newrelic.agent.tracers.Tracer)263 Test (org.junit.Test)195 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)104 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)99 Transaction (com.newrelic.agent.Transaction)86 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)54 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)41 ExitTracer (com.newrelic.agent.bridge.ExitTracer)39 TokenImpl (com.newrelic.agent.TokenImpl)35 StartAndThenLink (com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink)31 OtherRootSqlTracer (com.newrelic.agent.tracers.OtherRootSqlTracer)25 TransactionData (com.newrelic.agent.TransactionData)24 HashMap (java.util.HashMap)24 SqlTracer (com.newrelic.agent.tracers.SqlTracer)20 ArrayList (java.util.ArrayList)19 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)17 TransactionStats (com.newrelic.agent.stats.TransactionStats)16 MockRPMService (com.newrelic.agent.MockRPMService)15 JSONArray (org.json.simple.JSONArray)15 JSONObject (org.json.simple.JSONObject)14