ScheduledTransactionTrace
ERROR
LikelyError
Summary
Scheduled operation must start a new New Relic transaction
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("ScheduledTransactionTrace")
to the enclosing element.Disable this pattern completely by adding
-Xep:ScheduledTransactionTrace:OFF
as compiler argument. Learn more.
Samples
Replacement
Shows the difference in example code before and after the bug pattern is applied.
import com.newrelic.api.agent.Trace;
import org.springframework.scheduling.annotation.Scheduled;
class A {
+ @Trace(dispatcher = true)
@Scheduled(fixedDelay = 1)
void scheduledButNotTraced() {}
@Scheduled(fixedDelay = 1)
- @Trace
+ @Trace(dispatcher = true)
void scheduledButImproperlyTraced1() {}
@Scheduled(fixedDelay = 1)
- @Trace(dispatcher = false)
+ @Trace(dispatcher = true)
void scheduledButImproperlyTraced2() {}
@Scheduled(fixedDelay = 1)
- @Trace(leaf = true)
+ @Trace(dispatcher = true, leaf = true)
void scheduledButImproperlyTraced3() {}
}
Identification
Shows code lines which will (not) be flagged by this bug pattern.
A //BUG: Diagnostic contains:
comment is placed above any violating line.
import com.newrelic.api.agent.Trace;
import org.springframework.scheduling.annotation.Scheduled;
class A {
void notScheduled() {}
@Scheduled(fixedDelay = 1)
// BUG: Diagnostic contains:
void scheduledButNotTraced() {}
@Scheduled(fixedDelay = 1)
// BUG: Diagnostic contains:
@Trace
void scheduledButImproperlyTraced1() {}
@Scheduled(fixedDelay = 1)
// BUG: Diagnostic contains:
@Trace(dispatcher = false)
void scheduledButImproperlyTraced2() {}
@Scheduled(fixedDelay = 1)
@Trace(dispatcher = true)
void scheduledAndProperlyTraced() {}
}
import org.springframework.scheduling.annotation.Scheduled;
class A {
@Scheduled(fixedDelay = 1)
void scheduledButNotTraced() {}
}