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