zifeihan commented on a change in pull request #6232:
URL: https://github.com/apache/skywalking/pull/6232#discussion_r560841594
##########
File path:
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/sampling/SamplingService.java
##########
@@ -114,4 +113,26 @@ public void forceSampled() {
private void resetSamplingFactor() {
samplingFactorHolder = new AtomicInteger(0);
}
+
+ /**
+ * Reset scheduledFuture to support samplingRate changed.
+ */
+ void resetScheduledFuture() {
+ if (scheduledFuture != null) {
+ scheduledFuture.cancel(true);
+ }
+ on = false;
+ if (samplingRateWatcher.getSamplingRate() > 0) {
+ 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(
+ "Agent sampling mechanism started. Sample {} traces in 3
seconds.",
+ samplingRateWatcher.getSamplingRate()
+ );
+ }
Review comment:
done.
##########
File path:
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java
##########
@@ -214,15 +213,12 @@ public WatcherHolder get(String name) {
@Override
public String toString() {
StringBuilder registerTableDescription = new StringBuilder();
- registerTableDescription.append("Following dynamic config property
are available.").append(LINE_SEPARATOR);
-
registerTableDescription.append("---------------------------------------------").append(LINE_SEPARATOR);
register.forEach((key, holder) -> {
AgentConfigChangeWatcher watcher = holder.getWatcher();
registerTableDescription.append("key:")
.append(key)
- .append(" value(current):")
- .append(watcher.value())
- .append(LINE_SEPARATOR);
+ .append("value(current):")
+ .append(watcher.value());
Review comment:
done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]