blob: 1c82b43878011f7f78569461b873d963d38b3665 [file] [log] [blame]
package org.cloudera.htrace.impl;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.cloudera.htrace.Sampler;
import org.cloudera.htrace.Trace;
/**
* A Sampler that returns true if and only if tracing is on the current thread.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class TrueIfTracingSampler implements Sampler<Object> {
private static TrueIfTracingSampler instance;
public static TrueIfTracingSampler getInstance() {
if (instance == null) {
instance = new TrueIfTracingSampler();
}
return instance;
}
private TrueIfTracingSampler() {
}
@Override
public boolean next(Object info) {
return Trace.isTracing();
}
}