Optimize logging of start/end transaction/span
@@ -137,12 +137,13 @@ public class ElasticApmTracer {
} else {
transaction = transactionPool.createInstance().start(this, traceContextHeader, nanoTime, sampler);
}
-
+ if (logger.isDebugEnabled()) {
logger.debug("startTransaction {} {", transaction);
if (logger.isTraceEnabled()) {
logger.trace("starting transaction at",
new RuntimeException("this exception is just used to record where the transaction has been started from"));
}
+ }
return transaction;
}
@@ -184,11 +185,13 @@ public class ElasticApmTracer {
} else {
span = createRealSpan(transaction, parentSpan, nanoTime);
}
+ if (logger.isDebugEnabled()) {
logger.debug("startSpan {} {", span);
if (logger.isTraceEnabled()) {
logger.trace("starting span at",
new RuntimeException("this exception is just used to record where the span has been started from"));
}
+ }
return span;
}
@@ -246,11 +249,13 @@ public class ElasticApmTracer {
@SuppressWarnings("ReferenceEquality")
public void endTransaction(Transaction transaction, boolean releaseActiveTransaction) {
+ if (logger.isDebugEnabled()) {
logger.debug("} endTransaction {}", transaction);
if (logger.isTraceEnabled()) {
logger.trace("ending transaction at",
new RuntimeException("this exception is just used to record where the transaction has been ended from"));
}
+ }
if (releaseActiveTransaction) {
if (currentTransaction.get() != null && currentTransaction.get() != transaction) {
logger.warn("Trying to end a transaction which is not the current (thread local) transaction!");
@@ -267,10 +272,12 @@ public class ElasticApmTracer {
@SuppressWarnings("ReferenceEquality")
public void endSpan(Span span, boolean releaseActiveSpan) {
+ if (logger.isDebugEnabled()) {
logger.debug("} endSpan {}", span.toString());
if (logger.isTraceEnabled()) {
logger.trace("ending span at", new RuntimeException("this exception is just used to record where the span has been ended from"));
}
+ }
if (releaseActiveSpan) {
if (currentSpan.get() != null && currentSpan.get() != span) {
logger.warn("Trying to end a span which is not the current (thread local) span!");
