wu-sheng commented on code in PR #9622: URL: https://github.com/apache/skywalking/pull/9622#discussion_r973719769
########## oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/trace/CacheReadLatencyThresholdsAndWatcher.java: ########## @@ -0,0 +1,79 @@ +/* + * 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.analyzer.provider.trace; + +import com.google.common.base.Splitter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.skywalking.oap.server.analyzer.module.AnalyzerModule; +import org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher; +import org.apache.skywalking.oap.server.library.module.ModuleProvider; + +public class CacheReadLatencyThresholdsAndWatcher extends ConfigChangeWatcher { + private AtomicReference<Map<String, Integer>> thresholds; + private final String initialSettingsString; + private volatile String dynamicSettingsString; + + public CacheReadLatencyThresholdsAndWatcher(String config, ModuleProvider provider) { + super(AnalyzerModule.NAME, provider, "slowCacheReadThreshold"); + thresholds = new AtomicReference<>(new HashMap<>()); + initialSettingsString = config; + + activeSetting(config); + } + + private void activeSetting(String config) { Review Comment: I noticed a potential bug in here, as same as `DBLatencyThresholdsAndWatcher#activeSetting`. This method doesn't set `default` if it doesn't exist in the provided value. So, in `getThreshold`, a NPE would through as we try to use `thresholds.get().get("default")` for an `int. We need to fix the existing(also update the change log to add a bug fix), also the new added two watchers. If there is no default, we should add a default value, as same as we set in the `application.yml`. NOTICE, `initialSettingsString` could be overridden by system env or manual changing. We need to hard code a default value inside this class. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
