Search in sources :

Example 31 with DefaultTracer

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

the class JsonTracer method generateRootWebTracer.

private DefaultTracer generateRootWebTracer(Long initTime) {
    DefaultTracer tracer = generateRootBackgroundTracer(initTime);
    Transaction.getTransaction().setWebRequest(new MockHttpRequest());
    Transaction.getTransaction().setWebResponse(new MockHttpResponse());
    return tracer;
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 32 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer 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;
}
Also used : ClassMethodMetricNameFormat(com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) JSONObject(org.json.simple.JSONObject) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 33 with DefaultTracer

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

the class CrossProcessTransactionStateImpl method doProcessInboundResponseHeaders.

private void doProcessInboundResponseHeaders(TracedMethod tracer, CrossProcessNameFormat crossProcessFormat, String host, boolean addRollupMetrics) {
    if (crossProcessFormat != null) {
        if (tracer instanceof DefaultTracer) {
            DefaultTracer dt = (DefaultTracer) tracer;
            String transactionId = crossProcessFormat.getTransactionId();
            if (transactionId != null && transactionId.length() > 0) {
                dt.setAgentAttribute(AttributeNames.TRANSACTION_TRACE_ID_PARAMETER_NAME, transactionId);
            }
            dt.setMetricNameFormat(crossProcessFormat);
            if (Agent.LOG.isFinestEnabled()) {
                Agent.LOG.log(Level.FINEST, "Received APP_DATA cross process response header for external call: {0} in transaction {1}", crossProcessFormat.toString(), tx);
            }
        }
        if (addRollupMetrics && !UNKNOWN_HOST.equals(host)) {
            tracer.addRollupMetricName(crossProcessFormat.getHostCrossProcessIdRollupMetricName());
        }
    }
    if (addRollupMetrics) {
        recordExternalMetrics(tracer, host);
    }
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer)

Example 34 with DefaultTracer

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

the class TransactionActivity method finishFlyweightTracer.

public void finishFlyweightTracer(TracedMethod parent, long startInNanos, long finishInNanos, String className, String methodName, String methodDesc, String metricName, String[] rollupMetricNames) {
    try {
        if (parent instanceof DefaultTracer) {
            DefaultTracer parentTracer = (DefaultTracer) parent;
            long duration = finishInNanos - startInNanos;
            if (!flyweightInProgress) {
                Agent.LOG.log(Level.FINEST, "Error finishing tracer - the last tracer is of the wrong type.");
            }
            if (duration < 0) {
                Agent.LOG.log(Level.FINEST, "A tracer finished with a negative duration.");
                return;
            }
            transactionStats.getScopedStats().getOrCreateResponseTimeStats(metricName).recordResponseTimeInNanos(duration);
            if (Agent.isDebugEnabled()) {
                Agent.LOG.log(Level.FINEST, "Finished flyweight tracer {0} ({1}.{2}{3})", metricName, className, methodName, methodDesc);
            }
            if (rollupMetricNames != null) {
                SimpleStatsEngine unscopedStats = transactionStats.getUnscopedStats();
                for (String name : rollupMetricNames) {
                    unscopedStats.getOrCreateResponseTimeStats(name).recordResponseTimeInNanos(duration);
                }
            }
            parentTracer.childTracerFinished(duration);
        }
    } catch (Throwable t) {
        Agent.LOG.log(Level.FINEST, t, "Error finishing tracer");
    } finally {
        flyweightInProgress = false;
    }
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine)

Example 35 with DefaultTracer

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

the class TransactionActivity method setRootTracer.

private void setRootTracer(Tracer tracer) {
    rootTracer = tracer;
    lastTracer = tracer;
    if (tracer instanceof DefaultTracer) {
        DefaultTracer dt = (DefaultTracer) tracer;
        // Only check limits if in a transaction
        dt.setAttribute("async_context", asyncContext, !tracer.isAsync(), false);
    }
    if (!tracer.isAsync() && transaction != null) {
        transaction.activityStarted(this);
    }
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer)

Aggregations

DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)46 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)24 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)20 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)19 Transaction (com.newrelic.agent.Transaction)17 Tracer (com.newrelic.agent.tracers.Tracer)16 Test (org.junit.Test)14 TransactionData (com.newrelic.agent.TransactionData)6 ClassMethodMetricNameFormat (com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat)6 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)6 SqlTraceConfig (com.newrelic.agent.config.SqlTraceConfig)5 OtherRootSqlTracer (com.newrelic.agent.tracers.OtherRootSqlTracer)5 JSONObject (org.json.simple.JSONObject)5 MockDispatcher (com.newrelic.agent.MockDispatcher)4 DefaultSqlTracer (com.newrelic.agent.tracers.DefaultSqlTracer)4 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)4 HashMap (java.util.HashMap)4 TransactionActivity (com.newrelic.agent.TransactionActivity)3 ExitTracer (com.newrelic.agent.bridge.ExitTracer)3 ServerProp (com.newrelic.agent.config.ServerProp)3