Remove filename suffix in the meter active file config (#6413)

This commit is contained in:
mrproliu 2021-02-21 08:35:38 +08:00 committed by GitHub
parent 430a85df07
commit 317a6580f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 8 deletions

View File

@ -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.

View File

@ -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<String> meterAnalyzerActiveFileNames() {
if (StringUtils.isEmpty(this.meterAnalyzerActiveFiles)) {
return null;
}
return this.meterAnalyzerActiveFiles.split(",");
return Splitter.on(",").splitToList(this.meterAnalyzerActiveFiles);
}
}

View File

@ -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<MeterConfig> loadConfig(String path, String[] fileNames) throws ModuleStartException {
if (fileNames == null || fileNames.length == 0) {
public static List<MeterConfig> loadConfig(String path, List<String> 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) {

View File

@ -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}

View File

@ -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

View File

@ -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