public class DynamicSampleRateTraceFilter extends Object implements com.github.kristofa.brave.TraceFilter
DynamicSampleRateTraceFilter is an implementation of TraceFilter
that determines whether to trace requests using TracingConfiguration.
Globally tracing can be turned on/off by using config flag TracingConfiguration.enableTracing().
Once tracing is turned on globally, tracing for individual URLs can be controlled using map config
TracingConfiguration.getSampleRateMap(). It is read only when global tracing is toggled from off to on.
Once the config is read, it won't be reloaded until global tracing is switched off and on again.
Current sampling counter per URL is kept in an instance of FixedSampleRateTraceFilter which shouldn't be
reconstructed for every request. Hence we avoid reading this config once read into memory.
Ex: To turn on tracing for all requests, use
TracingConfiguration.enableTracing() should return true
TracingConfiguration.getSampleRateMap() should return {"*": 1}
TracingConfiguration.enableTracing() should return true
TracingConfiguration.getSampleRateMap() should return {"/some_api": 100, "/some_other_api": 50}
| Constructor and Description |
|---|
DynamicSampleRateTraceFilter(TracingConfiguration tracingConfiguration) |
public DynamicSampleRateTraceFilter(TracingConfiguration tracingConfiguration)
public boolean trace(String requestName)
trace in interface com.github.kristofa.brave.TraceFilterpublic void close()
close in interface com.github.kristofa.brave.TraceFilterCopyright © 2016. All rights reserved.