Skip to content

Commit

Permalink
do not record queue time before JFR is initialised
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstartin committed Oct 3, 2023
1 parent d4ca13f commit 578a615
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datadog.trace.api.profiling.Timer;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import datadog.trace.bootstrap.instrumentation.jfr.InstrumentationBasedProfiling;

public class QueueTimerHelper {

Expand All @@ -14,7 +15,9 @@ public static <T> void startQueuingTimer(
}

public static void startQueuingTimer(State state, Class<?> schedulerClass, Object task) {
if (task != null && state != null) {
// avoid calling this before JFR is initialised because it will lead to reading the wrong
// TSC frequency before JFR has set it up properly
if (task != null && state != null && InstrumentationBasedProfiling.isJFRReady()) {
QueueTiming timing =
(QueueTiming) AgentTracer.get().getTimer().start(Timer.TimerType.QUEUEING);
timing.setTask(task);
Expand Down

0 comments on commit 578a615

Please sign in to comment.