org.htrace
Interface Sampler<T>
- All Known Implementing Classes:
- AlwaysSampler, CountSampler, NeverSampler, ProbabilitySampler, TrueIfTracingSampler
public interface Sampler<T>
Extremely simple callback to determine the frequency that an action should be
performed.
'T' is the object type you require to create a more advanced sampling
function. For example if there is some RPC information in a 'Call' object,
you might implement Sampler. Then when the RPC is received you can call
one of the Trace.java functions that takes the extra 'info' parameter, which
will be passed into the next function you implemented.
For the example above, the next(T info) function may look like this
public boolean next(T info){
if (info == null) {
return false;
} else if (info.getName().equals("get")) {
return Math.random() > 0.5;
} else if (info.getName().equals("put")) {
return Math.random() > 0.25;
} else {
return false;
}
}
This would trace 50% of all gets, 75% of all puts and would not trace any other requests.
|
Method Summary |
boolean |
next(T info)
|
ALWAYS
static final Sampler<?> ALWAYS
NEVER
static final Sampler<?> NEVER
next
boolean next(T info)
Copyright © 2014. All Rights Reserved.