Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rm metric type cache #875

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class SuperCache {
public List<String> resourceKeys;
public List<String> freePrefixes;

public Set<String> metricTypes;

public Set<String> integrationProducts;

public String getStringValue(String type, String k) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void load() throws Exception {
sc.getListValue("global_config", "resource_keys", Collections.singletonList("tenant"));
sc.freePrefixes =
sc.getListValue("global_config", "free_metric_prefix", Collections.emptyList());
sc.metricTypes = queryMetricTypes();
sc.integrationProducts = queryIntegrationProducts();
this.sc = sc;
ProdLog.info("[SuperCache] load end");
Expand All @@ -75,18 +74,6 @@ private Set<String> queryIntegrationProducts() {
.collect(Collectors.toSet());
}

private Set<String> queryMetricTypes() {
QueryWrapper<MetricInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.select("DISTINCT metric_type");
List<MetricInfo> metricInfoList = this.metricInfoMapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(metricInfoList)) {
return Collections.emptySet();
}
return metricInfoList.stream() //
.map(MetricInfo::getMetricType) //
.collect(Collectors.toSet());
}

@Override
public int periodInSeconds() {
return 60;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public class AlarmRuleLevelAuthorizationChecker extends AbstractQueryChecker
new HashSet<>(Arrays.asList("default", "gradual", "fixed"));
private static final Set<String> aggregators = new HashSet<>(Arrays.asList("sum", "avg", "min",
"max", "count", "none", "SUM", "AVG", "MIN", "MAX", "COUNT", "NONE"));
private static final Set<String> defaultMetricTypes =
new HashSet<>(Arrays.asList("message", "loadbalancing"));
private static final Set<String> defaultMetricTypes = new HashSet<>(
Arrays.asList("app", "cache", "log", "oss", "trace", "system", "metric", "service",
"function", "pg", "mongodb", "db", "miniProgram", "mysql", "message", "loadbalancing"));
// private static final Set<String> products = new HashSet<>(
// Arrays.asList("JVM", "Function", "OceanBase", "Tbase", "PortCheck", "System", "MiniProgram",
// "Spanner", "IoT", "APM", "Mysql", "SLB", "SOFAMQX", "Postgres", "Gateway"));
Expand Down Expand Up @@ -423,12 +424,9 @@ private LevelAuthorizationCheckResult checkRule(Map<String, Object> ruleMap, Str

private LevelAuthorizationCheckResult checkDatasources(List<DataSource> datasources,
String tenant, String workspace) {
Set<String> metricTypes = this.superCacheService.getSc().metricTypes;
Set<String> products = this.superCacheService.getSc().integrationProducts;
for (DataSource dataSource : datasources) {
if (StringUtils.isNotEmpty(dataSource.getMetricType())
&& !CollectionUtils.isEmpty(metricTypes)
&& !metricTypes.contains(dataSource.getMetricType())
&& !defaultMetricTypes.contains(dataSource.getMetricType())) {
return failCheckResult("invalid metric type %s", dataSource.getMetricType());
}
Expand Down
Loading