diff --git a/CHANGES.md b/CHANGES.md index 515d1ab93..d417d38a0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ Release Notes. * Enhance `MeterSystem` to allow creating metrics with same `metricName` / `function` / `scope`. * Storage plugin supports postgresql. * Fix kubernetes.client.opeanapi.ApiException. +* Remove filename suffix in the meter active file config. #### UI * Update selector scroller to show in all pages. diff --git a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java index f13ee999a..2d88c64c9 100644 --- a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java +++ b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java @@ -18,6 +18,7 @@ package org.apache.skywalking.oap.server.analyzer.provider; +import com.google.common.base.Splitter; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -145,10 +146,10 @@ public class AnalyzerModuleConfig extends ModuleConfig { /** * Get all files could be meter analyzed, files split by "," */ - public String[] meterAnalyzerActiveFileNames() { + public List meterAnalyzerActiveFileNames() { if (StringUtils.isEmpty(this.meterAnalyzerActiveFiles)) { return null; } - return this.meterAnalyzerActiveFiles.split(","); + return Splitter.on(",").splitToList(this.meterAnalyzerActiveFiles); } } diff --git a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfigs.java b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfigs.java index 09b539919..ac53413e7 100644 --- a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfigs.java +++ b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/config/MeterConfigs.java @@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.analyzer.provider.meter.config; import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.apache.skywalking.oap.server.library.util.CollectionUtils; import org.apache.skywalking.oap.server.library.util.ResourceUtils; import org.yaml.snakeyaml.Yaml; @@ -43,20 +44,26 @@ public class MeterConfigs { /** * Load all configs from path */ - public static List loadConfig(String path, String[] fileNames) throws ModuleStartException { - if (fileNames == null || fileNames.length == 0) { + public static List loadConfig(String path, List fileNames) throws ModuleStartException { + if (CollectionUtils.isEmpty(fileNames)) { return Collections.emptyList(); } File[] configs; try { - configs = ResourceUtils.getPathFiles(path, fileNames); + configs = ResourceUtils.getPathFiles(path); } catch (FileNotFoundException e) { throw new ModuleStartException("Load meter configs failed", e); } return Arrays.stream(configs) .map(f -> { + String fileName = f.getName(); + int dotIndex = fileName.lastIndexOf('.'); + fileName = (dotIndex == -1) ? fileName : fileName.substring(0, dotIndex); + if (!fileNames.contains(fileName)) { + return null; + } try (Reader r = new FileReader(f)) { return new Yaml().loadAs(r, MeterConfig.class); } catch (IOException e) { diff --git a/oap-server/server-bootstrap/src/main/resources/application.yml b/oap-server/server-bootstrap/src/main/resources/application.yml index 34b4bef10..9b5779ba2 100755 --- a/oap-server/server-bootstrap/src/main/resources/application.yml +++ b/oap-server/server-bootstrap/src/main/resources/application.yml @@ -225,7 +225,7 @@ agent-analyzer: # Exit spans with the component in the list would not generate the client-side instance relation metrics. noUpstreamRealAddressAgents: ${SW_NO_UPSTREAM_REAL_ADDRESS:6000,9000} slowTraceSegmentThreshold: ${SW_SLOW_TRACE_SEGMENT_THRESHOLD:-1} # Setting this threshold about the latency would make the slow trace segments sampled if they cost more time, even the sampling mechanism activated. The default value is `-1`, which means would not sample slow traces. Unit, millisecond. - meterAnalyzerActiveFiles: ${SW_METER_ANALYZER_ACTIVE_FILES:spring-sleuth.yaml} # Which files could be meter analyzed, files split by "," + meterAnalyzerActiveFiles: ${SW_METER_ANALYZER_ACTIVE_FILES:spring-sleuth} # Which files could be meter analyzed, files split by "," log-analyzer: selector: ${SW_LOG_ANALYZER:default} diff --git a/test/e2e/e2e-test/docker/kafka/docker-compose.meter.yml b/test/e2e/e2e-test/docker/kafka/docker-compose.meter.yml index 34df799e0..a67c97b48 100644 --- a/test/e2e/e2e-test/docker/kafka/docker-compose.meter.yml +++ b/test/e2e/e2e-test/docker/kafka/docker-compose.meter.yml @@ -26,7 +26,7 @@ services: SW_KAFKA_FETCHER_PARTITIONS: 2 SW_KAFKA_FETCHER_PARTITIONS_FACTOR: 1 SW_KAFKA_FETCHER_ENABLE_METER_SYSTEM: "true" - SW_METER_ANALYZER_ACTIVE_FILES: spring-sleuth.yaml + SW_METER_ANALYZER_ACTIVE_FILES: spring-sleuth depends_on: broker-a: condition: service_healthy diff --git a/test/e2e/e2e-test/docker/meter/docker-compose.yml b/test/e2e/e2e-test/docker/meter/docker-compose.yml index 1428528d8..4ddc44879 100644 --- a/test/e2e/e2e-test/docker/meter/docker-compose.yml +++ b/test/e2e/e2e-test/docker/meter/docker-compose.yml @@ -18,7 +18,7 @@ version: '2.1' services: oap: environment: - SW_METER_ANALYZER_ACTIVE_FILES: spring-sleuth.yaml + SW_METER_ANALYZER_ACTIVE_FILES: spring-sleuth extends: file: ../base-compose.yml service: oap