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;
}
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;
}
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);
}
}
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;
}
}
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);
}
}
Aggregations