chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
This commit is contained in:
43
metrics/seata-metrics-core/pom.xml
Normal file
43
metrics/seata-metrics-core/pom.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 1999-2019 Seata.io Group.
|
||||
~
|
||||
~ Licensed 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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>seata-metrics</artifactId>
|
||||
<groupId>io.seata</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>seata-metrics-core</artifactId>
|
||||
<name>seata-metrics-core ${project.version}</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.seata</groupId>
|
||||
<artifactId>seata-metrics-api</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>seata-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Seata.io Group.
|
||||
*
|
||||
* Licensed 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 io.seata.metrics.exporter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.seata.common.loader.EnhancedServiceLoader;
|
||||
import io.seata.common.util.StringUtils;
|
||||
import io.seata.config.ConfigurationFactory;
|
||||
import io.seata.core.constants.ConfigurationKeys;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Exporter Factory for load all configured exporters
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public class ExporterFactory {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ExporterFactory.class);
|
||||
|
||||
public static List<Exporter> getInstanceList() {
|
||||
List<Exporter> exporters = new ArrayList<>();
|
||||
String exporterTypeNameList = ConfigurationFactory.getInstance().getConfig(
|
||||
ConfigurationKeys.METRICS_PREFIX + ConfigurationKeys.METRICS_EXPORTER_LIST, null);
|
||||
if (!StringUtils.isNullOrEmpty(exporterTypeNameList)) {
|
||||
String[] exporterTypeNames = exporterTypeNameList.split(",");
|
||||
for (String exporterTypeName : exporterTypeNames) {
|
||||
ExporterType exporterType;
|
||||
try {
|
||||
exporterType = ExporterType.getType(exporterTypeName);
|
||||
exporters.add(
|
||||
EnhancedServiceLoader.load(Exporter.class, Objects.requireNonNull(exporterType).getName()));
|
||||
} catch (Exception exx) {
|
||||
LOGGER.error("not support metrics exporter type: {}",exporterTypeName, exx);
|
||||
}
|
||||
}
|
||||
}
|
||||
return exporters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Seata.io Group.
|
||||
*
|
||||
* Licensed 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 io.seata.metrics.exporter;
|
||||
|
||||
/**
|
||||
* Supported metrics exporter type
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public enum ExporterType {
|
||||
/**
|
||||
* Export metrics data to Prometheus
|
||||
*/
|
||||
PROMETHEUS("prometheus");
|
||||
|
||||
private String name;
|
||||
|
||||
ExporterType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static ExporterType getType(String name) {
|
||||
if (PROMETHEUS.name().equalsIgnoreCase(name)) {
|
||||
return PROMETHEUS;
|
||||
} else {
|
||||
throw new IllegalArgumentException("not support exporter type: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Seata.io Group.
|
||||
*
|
||||
* Licensed 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 io.seata.metrics.registry;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.seata.common.exception.NotSupportYetException;
|
||||
import io.seata.common.loader.EnhancedServiceLoader;
|
||||
import io.seata.common.util.StringUtils;
|
||||
import io.seata.config.ConfigurationFactory;
|
||||
import io.seata.core.constants.ConfigurationKeys;
|
||||
|
||||
/**
|
||||
* Registry Factory for load configured metrics registry
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public class RegistryFactory {
|
||||
public static Registry getInstance() {
|
||||
RegistryType registryType;
|
||||
String registryTypeName = ConfigurationFactory.getInstance().getConfig(
|
||||
ConfigurationKeys.METRICS_PREFIX + ConfigurationKeys.METRICS_REGISTRY_TYPE, null);
|
||||
if (!StringUtils.isNullOrEmpty(registryTypeName)) {
|
||||
try {
|
||||
registryType = RegistryType.getType(registryTypeName);
|
||||
} catch (Exception exx) {
|
||||
throw new NotSupportYetException("not support metrics registry type: " + registryTypeName);
|
||||
}
|
||||
return EnhancedServiceLoader.load(Registry.class, Objects.requireNonNull(registryType).getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Seata.io Group.
|
||||
*
|
||||
* Licensed 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 io.seata.metrics.registry;
|
||||
|
||||
/**
|
||||
* Supported metrics registry type
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public enum RegistryType {
|
||||
/**
|
||||
* Built-in compact metrics registry
|
||||
*/
|
||||
COMPACT("compact");
|
||||
|
||||
private String name;
|
||||
|
||||
RegistryType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static RegistryType getType(String name) {
|
||||
if (COMPACT.name().equalsIgnoreCase(name)) {
|
||||
return COMPACT;
|
||||
} else {
|
||||
throw new IllegalArgumentException("not support registry type: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user