Fix a thread leak in `SamplingService` when updated sampling policy in the runtime. (#487)
This commit is contained in:
parent
e91514c634
commit
c0b4447540
|
|
@ -22,6 +22,7 @@ Release Notes.
|
|||
* Fix thrift plugin generate duplicate traceid when `sendBase` error occurs
|
||||
* Support keep trace profiling when cross-thread.
|
||||
* Fix unexpected whitespace of the command catalogs in several Redis plugins.
|
||||
* Fix a thread leak in `SamplingService` when updated sampling policy in the runtime.
|
||||
|
||||
#### Documentation
|
||||
* Update docs of Tracing APIs, reorganize the API docs into six parts.
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public class SamplingService implements BootService {
|
|||
private volatile ScheduledFuture<?> scheduledFuture;
|
||||
|
||||
private SamplingRateWatcher samplingRateWatcher;
|
||||
private ScheduledExecutorService service;
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
|
|
@ -58,6 +59,8 @@ public class SamplingService implements BootService {
|
|||
|
||||
@Override
|
||||
public void boot() {
|
||||
service = Executors.newSingleThreadScheduledExecutor(
|
||||
new DefaultNamedThreadFactory("SamplingService"));
|
||||
samplingRateWatcher = new SamplingRateWatcher("agent.sample_n_per_3_secs", this);
|
||||
ServiceManager.INSTANCE.findService(ConfigurationDiscoveryService.class)
|
||||
.registerAgentConfigChangeWatcher(samplingRateWatcher);
|
||||
|
|
@ -118,8 +121,6 @@ public class SamplingService implements BootService {
|
|||
if (!on) {
|
||||
on = true;
|
||||
this.resetSamplingFactor();
|
||||
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(
|
||||
new DefaultNamedThreadFactory("SamplingService"));
|
||||
scheduledFuture = service.scheduleAtFixedRate(new RunnableWithExceptionProtection(
|
||||
this::resetSamplingFactor, t -> LOGGER.error("unexpected exception.", t)), 0, 3, TimeUnit.SECONDS);
|
||||
LOGGER.debug(
|
||||
|
|
|
|||
Loading…
Reference in New Issue