public static long safeGetThreadCpuTime() { if (!isThreadCpuTimeEnabled()) { return 0L; } else { return getCurrentThreadCpuTime(); } }
public static <T> QueryRunner<T> safeBuild( QueryRunner<T> delegate, QueryToolChest<T, ? extends Query<T>> queryToolChest, ServiceEmitter emitter, AtomicLong accumulator, boolean report ) { if (!JvmUtils.isThreadCpuTimeEnabled()) { return delegate; } else { return new CPUTimeMetricQueryRunner<>(delegate, queryToolChest, emitter, accumulator, report); } } }
private CPUTimeMetricQueryRunner( QueryRunner<T> delegate, QueryToolChest<T, ? extends Query<T>> queryToolChest, ServiceEmitter emitter, AtomicLong cpuTimeAccumulator, boolean report ) { if (!JvmUtils.isThreadCpuTimeEnabled()) { throw new ISE("Cpu time must enabled"); } this.delegate = delegate; this.queryToolChest = queryToolChest; this.emitter = emitter; this.cpuTimeAccumulator = cpuTimeAccumulator == null ? new AtomicLong(0L) : cpuTimeAccumulator; this.report = report; }