hooksOpt = Mixer.configurationHooksNullable();
- if (hooksOpt.isPresent()) {
- ConfigurationHooks hooks = hooksOpt.get();
- String fileName = "capa-component-telemetry-sampling.properties";
- try {
- // TODO: 2021/12/3 Move this to SPI module.
- // TODO: 2021/12/3 And use Configuration extension api to get merged file.
- MergedPropertiesConfig config = new MergedPropertiesConfig(
- fileName,
- hooks.defaultConfigurationAppId(),
- CapaTelemetryProperties.Settings.getCenterConfigAppId());
- String metricKey = "metricsEnable";
- String traceKey = "traceEnable";
- SamplerConfig dynamicConfig = new SamplerConfig() {
- @Override
- public Boolean isMetricsEnable() {
- return !config.containsKey(metricKey) || Boolean.TRUE.toString()
- .equalsIgnoreCase(config.get(metricKey));
- }
-
- @Override
- public Boolean isTraceEnable() {
- return !config.containsKey(traceKey) || Boolean.TRUE.toString()
- .equalsIgnoreCase(config.get(traceKey));
- }
- };
-
- REMOTE_CONFIG.set(dynamicConfig);
-
- return true;
- } catch (Throwable throwable) {
- log.info("Fail to load global telemetry config. Dynamic global config is disabled for capa telemetry.",
- throwable);
- }
- }
- return false;
- }
-
public Boolean isMetricsEnable() {
return metricsEnable == null ? DEFAULT_SUPPLIER.get().metricsEnable : metricsEnable;
}
diff --git a/sdk-component/src/test/java/group/rxcloud/capa/component/telemetry/SamplerConfigTest.java b/sdk-component/src/test/java/group/rxcloud/capa/component/telemetry/SamplerConfigTest.java
index 5e4120b..b36b505 100644
--- a/sdk-component/src/test/java/group/rxcloud/capa/component/telemetry/SamplerConfigTest.java
+++ b/sdk-component/src/test/java/group/rxcloud/capa/component/telemetry/SamplerConfigTest.java
@@ -18,9 +18,9 @@
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author: chenyijiang
@@ -31,19 +31,20 @@ public class SamplerConfigTest {
@Test
public void isMetricsEnable() {
- assertFalse(SamplerConfig.DEFAULT_SUPPLIER.get().isMetricsEnable());
+ assertTrue(SamplerConfig.DEFAULT_SUPPLIER.get().isMetricsEnable());
}
@Test
public void isTraceEnable() {
- assertFalse(SamplerConfig.DEFAULT_SUPPLIER.get().isTraceEnable());
+ assertTrue(SamplerConfig.DEFAULT_SUPPLIER.get().isTraceEnable());
}
+
@Test
public void configurationWeakDependency() {
for (int i = 0; i < 6; i++) {
SamplerConfig config = SamplerConfig.DEFAULT_SUPPLIER.get();
assertNotNull(config);
- assertNotEquals(SamplerConfig.DEFAULT_CONFIG, config);
+ assertEquals(SamplerConfig.DEFAULT_CONFIG, config);
}
}
}
\ No newline at end of file
diff --git a/sdk-infrastructure/src/main/java/group/rxcloud/capa/infrastructure/hook/MergedPropertiesConfig.java b/sdk-infrastructure/src/main/java/group/rxcloud/capa/infrastructure/hook/MergedPropertiesConfig.java
deleted file mode 100644
index fce050e..0000000
--- a/sdk-infrastructure/src/main/java/group/rxcloud/capa/infrastructure/hook/MergedPropertiesConfig.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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 group.rxcloud.capa.infrastructure.hook;
-
-import group.rxcloud.cloudruntimes.domain.core.configuration.SubConfigurationResp;
-import group.rxcloud.cloudruntimes.utils.TypeRef;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import reactor.core.publisher.Flux;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReferenceArray;
-
-/**
- * Config provider to merge multiple properties file which takes the input order as their priority.
- *
- *
- * TODO: 2021/12/3 This should not in infrastructure layer.
- * TODO: 2021/12/3 Use Configuration extension api to get merged file.
- */
-@Deprecated
-public class MergedPropertiesConfig {
-
- private static final Logger log = LoggerFactory.getLogger(MergedPropertiesConfig.class);
-
- private final String fileName;
-
- private final AtomicReferenceArray