chore(project): 添加项目配置文件和忽略规则

- 添加 Babel 配置文件支持 ES6+ 语法转换
- 添加 ESLint 忽略规则和配置文件
- 添加 Git 忽略规则文件
- 添加 Travis CI 配置文件
- 添加 1.4.2 版本变更日志文件
- 添加 Helm 图表辅助模板文件
- 添加 Helm 忽略规则文件
This commit is contained in:
2026-03-27 17:36:48 +08:00
commit c2453d6434
1703 changed files with 277582 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?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-exporter-prometheus</artifactId>
<name>seata-metrics-exporter-prometheus ${project.version}</name>
<properties>
<prometheus.client.version>0.6.0</prometheus.client.version>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-metrics-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_httpserver</artifactId>
<version>${prometheus.client.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,96 @@
/*
* 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.prometheus;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import io.prometheus.client.Collector;
import io.prometheus.client.Collector.MetricFamilySamples.Sample;
import io.prometheus.client.exporter.HTTPServer;
import io.seata.common.loader.LoadLevel;
import io.seata.config.ConfigurationFactory;
import io.seata.core.constants.ConfigurationKeys;
import io.seata.metrics.Measurement;
import io.seata.metrics.exporter.Exporter;
import io.seata.metrics.registry.Registry;
import static io.seata.core.constants.ConfigurationKeys.METRICS_EXPORTER_PROMETHEUS_PORT;
/**
* Exporter for Prometheus
*
* @author zhengyangyong
*/
@LoadLevel(name = "prometheus", order = 1)
public class PrometheusExporter extends Collector implements Collector.Describable, Exporter {
private final HTTPServer server;
private Registry registry;
public PrometheusExporter() throws IOException {
int port = ConfigurationFactory.getInstance().getInt(
ConfigurationKeys.METRICS_PREFIX + METRICS_EXPORTER_PROMETHEUS_PORT, 9898);
this.server = new HTTPServer(port, true);
this.register();
}
@Override
public void setRegistry(Registry registry) {
this.registry = registry;
}
@Override
public List<MetricFamilySamples> collect() {
List<MetricFamilySamples> familySamples = new ArrayList<>();
if (registry != null) {
Iterable<Measurement> measurements = registry.measure();
List<Sample> samples = new ArrayList<>();
measurements.forEach(measurement -> samples.add(convertMeasurementToSample(measurement)));
if (!samples.isEmpty()) {
familySamples.add(new MetricFamilySamples("seata", Type.UNTYPED, "seata", samples));
}
}
return familySamples;
}
private Sample convertMeasurementToSample(Measurement measurement) {
String prometheusName = measurement.getId().getName().replace(".", "_");
List<String> labelNames = new ArrayList<>();
List<String> labelValues = new ArrayList<>();
for (Entry<String, String> tag : measurement.getId().getTags()) {
labelNames.add(tag.getKey());
labelValues.add(tag.getValue());
}
return new Sample(prometheusName, labelNames, labelValues, measurement.getValue(),
(long)measurement.getTimestamp());
}
@Override
public List<MetricFamilySamples> describe() {
return collect();
}
@Override
public void close() {
server.stop();
}
}

View File

@@ -0,0 +1 @@
io.seata.metrics.exporter.prometheus.PrometheusExporter