wu-sheng commented on a change in pull request #4987:
URL: https://github.com/apache/skywalking/pull/4987#discussion_r448676691



##########
File path: 
oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceSampleRateWatcher.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.receiver.trace.provider;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.receiver.trace.module.TraceModule;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+@Slf4j
+public class TraceSampleRateWatcher extends ConfigChangeWatcher {
+    private  AtomicReference<String> settingsString;
+    private  AtomicReference<Integer> sampleRate;
+
+    public TraceSampleRateWatcher(String config, TraceModuleProvider provider) 
{
+        super(TraceModule.NAME, provider, "sampleRate");
+        settingsString = new AtomicReference<>(Const.EMPTY_STRING);
+        sampleRate = new AtomicReference<>();
+
+        activeSetting(config);
+    }
+
+    private void activeSetting(String config) {
+        if (log.isDebugEnabled()) {
+            log.debug("Updating using new static config: {}", config);
+        }
+        settingsString.set(config);
+        try {
+            sampleRate.set(Integer.parseInt(config));
+        } catch (NumberFormatException ex) {
+            log.error("Cannot load sampleRate from: {}", config, ex);
+        }
+    }
+
+    @Override
+    public void notify(ConfigChangeEvent value) {
+        if (EventType.DELETE.equals(value.getEventType())) {
+            activeSetting("");

Review comment:
       What is the expected sampling rate if the delete happens?

##########
File path: 
oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceModuleProvider.java
##########
@@ -75,8 +77,11 @@ public void prepare() throws ServiceNotProvidedException {
 
         uninstrumentedGatewaysConfig = new UninstrumentedGatewaysConfig(this);
 
+        traceSampleRateWatcher = new 
TraceSampleRateWatcher(String.valueOf(moduleConfig.getSampleRate()), this);

Review comment:
       I think should not change to String here, please move this into the 
`TraceSampleRateWatcher`.

##########
File path: 
oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceSampleRateWatcher.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.receiver.trace.provider;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.receiver.trace.module.TraceModule;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+@Slf4j
+public class TraceSampleRateWatcher extends ConfigChangeWatcher {
+    private  AtomicReference<String> settingsString;

Review comment:
       I think you don't need `settingsString`




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to