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,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-registry-compact</artifactId>
<name>seata-metrics-registry-compact ${project.version}</name>
<dependencies>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-metrics-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,73 @@
/*
* 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.compact;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicLong;
import io.seata.metrics.Clock;
import io.seata.metrics.Counter;
import io.seata.metrics.Id;
import io.seata.metrics.Measurement;
import io.seata.metrics.SystemClock;
/**
* Compact Counter implement with AtomicLong
*
* @author zhengyangyong
*/
public class CompactCounter implements Counter {
private final Id id;
private final AtomicLong counter;
private final Clock clock;
public CompactCounter(Id id) {
this(id, SystemClock.INSTANCE);
}
public CompactCounter(Id id, Clock clock) {
this.id = id;
this.counter = new AtomicLong(0);
this.clock = clock;
}
@Override
public Id getId() {
return id;
}
@Override
public long increase(long value) {
return counter.addAndGet(value);
}
@Override
public long decrease(long value) {
return increase(-1 * value);
}
@Override
public long get() {
return counter.get();
}
@Override
public Iterable<Measurement> measure() {
return Collections.singletonList(new Measurement(id, clock.getCurrentMilliseconds(), counter.get()));
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.compact;
import java.util.Collections;
import java.util.function.Supplier;
import io.seata.metrics.Clock;
import io.seata.metrics.Gauge;
import io.seata.metrics.Id;
import io.seata.metrics.Measurement;
import io.seata.metrics.SystemClock;
/**
* Compact Gauge implement with Supplier
*
* @author zhengyangyong
*/
public class CompactGauge<T extends Number> implements Gauge<T> {
private final Id id;
private final Supplier<T> supplier;
private final Clock clock;
public CompactGauge(Id id, Supplier<T> supplier) {
this(id, supplier, SystemClock.INSTANCE);
}
public CompactGauge(Id id, Supplier<T> supplier, Clock clock) {
this.id = id;
this.supplier = supplier;
this.clock = clock;
}
@Override
public T get() {
return supplier.get();
}
@Override
public Id getId() {
return id;
}
@Override
public Iterable<Measurement> measure() {
return Collections.singletonList(new Measurement(id, clock.getCurrentMilliseconds(), get().doubleValue()));
}
}

View File

@@ -0,0 +1,75 @@
/*
* 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.compact;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import io.seata.common.loader.LoadLevel;
import io.seata.common.util.CollectionUtils;
import io.seata.metrics.Counter;
import io.seata.metrics.Gauge;
import io.seata.metrics.Id;
import io.seata.metrics.Measurement;
import io.seata.metrics.Meter;
import io.seata.metrics.registry.Registry;
import io.seata.metrics.Summary;
import io.seata.metrics.Timer;
/**
* Compact Registry implement, this registry only compute all Measurements when call measure method and do not cache
*
* @author zhengyangyong
*/
@LoadLevel(name = "compact", order = 1)
public class CompactRegistry implements Registry {
private static final Map<UUID, Meter> METERS = new ConcurrentHashMap<>();
@Override
public <T extends Number> Gauge<T> getGauge(Id id, Supplier<T> supplier) {
return (Gauge<T>)CollectionUtils.computeIfAbsent(METERS, id.getId(), key -> new CompactGauge<>(id, supplier));
}
@Override
public Counter getCounter(Id id) {
return (Counter)CollectionUtils.computeIfAbsent(METERS, id.getId(), key -> new CompactCounter(id));
}
@Override
public Summary getSummary(Id id) {
return (Summary)CollectionUtils.computeIfAbsent(METERS, id.getId(), key -> new CompactSummary(id));
}
@Override
public Timer getTimer(Id id) {
return (Timer)CollectionUtils.computeIfAbsent(METERS, id.getId(), key -> new CompactTimer(id));
}
@Override
public Iterable<Measurement> measure() {
final List<Measurement> measurements = new ArrayList<>();
if (METERS.isEmpty()) {
return measurements;
}
METERS.values().iterator()
.forEachRemaining(meter -> meter.measure().forEach(measurements::add));
return measurements;
}
}

View File

@@ -0,0 +1,95 @@
/*
* 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.compact;
import java.util.Arrays;
import io.seata.metrics.Clock;
import io.seata.metrics.Id;
import io.seata.metrics.Measurement;
import io.seata.metrics.Summary;
import io.seata.metrics.SystemClock;
import io.seata.metrics.IdConstants;
/**
* Compact Summary implement with SummaryValue
*
* @author zhengyangyong
*/
public class CompactSummary implements Summary {
private final Id id;
private final Id countId;
private final Id totalId;
private final Id tpsId;
private volatile SummaryValue value;
private final Clock clock;
public CompactSummary(Id id) {
this(id, SystemClock.INSTANCE);
}
public CompactSummary(Id id, Clock clock) {
this.id = id;
this.countId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_COUNT);
this.totalId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_TOTAL);
this.tpsId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_TPS);
this.value = new SummaryValue(clock.getCurrentMilliseconds());
this.clock = clock;
}
@Override
public Id getId() {
return id;
}
@Override
public void increase(long value) {
this.value.increase(value);
}
@Override
public long total() {
return this.value.getTotal();
}
@Override
public long count() {
return this.value.getCount();
}
@Override
public double tps() {
return this.value.getTps(clock.getCurrentMilliseconds());
}
@Override
public Iterable<Measurement> measure() {
SummaryValue value = this.value;
double time = clock.getCurrentMilliseconds();
this.value = new SummaryValue(time);
return Arrays.asList(new Measurement(countId, time, value.getCount()),
new Measurement(totalId, time, value.getTotal()),
new Measurement(tpsId, time, value.getTps(time)));
}
}

View File

@@ -0,0 +1,107 @@
/*
* 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.compact;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import io.seata.metrics.Clock;
import io.seata.metrics.Id;
import io.seata.metrics.Measurement;
import io.seata.metrics.SystemClock;
import io.seata.metrics.Timer;
import io.seata.metrics.IdConstants;
/**
* Compact Timer implement with TimerValue
*
* @author zhengyangyong
*/
public class CompactTimer implements Timer {
private final Id id;
private final Id countId;
private final Id totalId;
private final Id maxId;
private final Id averageId;
private volatile TimerValue value;
private final Clock clock;
public CompactTimer(Id id) {
this(id, SystemClock.INSTANCE);
}
public CompactTimer(Id id, Clock clock) {
this.id = id;
this.countId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_COUNT);
this.totalId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_TOTAL);
this.maxId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_MAX);
this.averageId = new Id(id.getName()).withTag(id.getTags())
.withTag(IdConstants.STATISTIC_KEY, IdConstants.STATISTIC_VALUE_AVERAGE);
this.value = new TimerValue();
this.clock = clock;
}
@Override
public Id getId() {
return id;
}
@Override
public void record(long value, TimeUnit unit) {
this.value.record(value, unit);
}
@Override
public long count() {
return this.value.getCount();
}
@Override
public long total() {
return this.value.getTotal();
}
@Override
public long max() {
return this.value.getMax();
}
@Override
public double average() {
return this.value.getAverage();
}
@Override
public Iterable<Measurement> measure() {
//reset value when measure
double time = clock.getCurrentMilliseconds();
TimerValue value = this.value;
this.value = new TimerValue();
return Arrays.asList(new Measurement(countId, time, value.getCount()),
new Measurement(totalId, time, value.getTotal() * 0.001),
new Measurement(maxId, time, value.getMax() * 0.001),
new Measurement(averageId, time, value.getAverage() * 0.001));
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.compact;
import java.util.concurrent.atomic.LongAdder;
/**
* Record container for CompactSummary
*
* @author zhengyangyong
*/
public class SummaryValue {
private final LongAdder count;
private final LongAdder total;
private final double startMilliseconds;
public long getCount() {
return count.longValue();
}
public long getTotal() {
return total.longValue();
}
public double getTps(double currentMilliseconds) {
if (currentMilliseconds <= startMilliseconds) {
return 0;
}
return total.doubleValue() / (currentMilliseconds - startMilliseconds) * 1000.0;
}
public SummaryValue(double startMilliseconds) {
this.count = new LongAdder();
this.total = new LongAdder();
this.startMilliseconds = startMilliseconds;
}
public void increase() {
this.increase(1);
}
public void increase(long value) {
if (value < 0) {
return;
}
this.count.increment();
this.total.add(value);
}
}

View File

@@ -0,0 +1,67 @@
/*
* 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.compact;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;
/**
* Record container for CompactTimer
*
* @author zhengyangyong
*/
public class TimerValue {
private final LongAdder count;
private final LongAdder total;
private final AtomicLong max;
public long getCount() {
return count.longValue();
}
public long getTotal() {
return total.longValue();
}
public long getMax() {
return max.get();
}
public double getAverage() {
double count = this.count.doubleValue();
double total = this.total.doubleValue();
return count == 0 ? 0 : total / count;
}
public TimerValue() {
this.count = new LongAdder();
this.total = new LongAdder();
this.max = new AtomicLong(0);
}
public void record(long value, TimeUnit unit) {
if (value < 0) {
return;
}
long changeValue = unit == TimeUnit.MICROSECONDS ? value : TimeUnit.MICROSECONDS.convert(value, unit);
this.count.increment();
this.total.add(changeValue);
this.max.accumulateAndGet(changeValue, Math::max);
}
}

View File

@@ -0,0 +1 @@
io.seata.metrics.registry.compact.CompactRegistry