chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
This commit is contained in:
29
metrics/seata-metrics-api/pom.xml
Normal file
29
metrics/seata-metrics-api/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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-api</artifactId>
|
||||
<name>seata-metrics-api ${project.version}</name>
|
||||
</project>
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Clock interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Clock {
|
||||
double getCurrentMilliseconds();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Counter interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Counter extends Meter {
|
||||
long increase(long value);
|
||||
|
||||
long decrease(long value);
|
||||
|
||||
long get();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Gauge interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Gauge<T extends Number> extends Meter {
|
||||
T get();
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Meter id
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public class Id {
|
||||
private final UUID id;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final SortedMap<String, String> tags;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Iterable<Entry<String, String>> getTags() {
|
||||
return tags.entrySet();
|
||||
}
|
||||
|
||||
public int getTagCount() {
|
||||
return tags.size();
|
||||
}
|
||||
|
||||
public Id(String name) {
|
||||
this.id = UUID.randomUUID();
|
||||
this.name = name;
|
||||
this.tags = new TreeMap<>();
|
||||
}
|
||||
|
||||
public Id withTag(String name, String value) {
|
||||
this.tags.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Id withTag(Iterable<Entry<String, String>> tags) {
|
||||
if (tags != null) {
|
||||
for (Entry<String, String> tag : tags) {
|
||||
this.tags.put(tag.getKey(), tag.getValue());
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(name);
|
||||
builder.append("(");
|
||||
if (tags.size() == 0) {
|
||||
builder.append(")");
|
||||
return builder.toString();
|
||||
}
|
||||
for (Entry<String, String> tag : tags.entrySet()) {
|
||||
builder.append(String.format("%s=%s,", tag.getKey(), tag.getValue()));
|
||||
}
|
||||
builder.delete(builder.length() - 1, builder.length());
|
||||
builder.append(")");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Seata metrics constants for id
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface IdConstants {
|
||||
String SEATA_TRANSACTION = "seata.transaction";
|
||||
|
||||
String APP_ID_KEY = "applicationId";
|
||||
|
||||
String GROUP_KEY = "group";
|
||||
|
||||
String NAME_KEY = "name";
|
||||
|
||||
String ROLE_KEY = "role";
|
||||
|
||||
String METER_KEY = "meter";
|
||||
|
||||
String STATISTIC_KEY = "statistic";
|
||||
|
||||
String STATUS_KEY = "status";
|
||||
|
||||
String ROLE_VALUE_TC = "tc";
|
||||
|
||||
String ROLE_VALUE_TM = "tm";
|
||||
|
||||
String ROLE_VALUE_RM = "rm";
|
||||
|
||||
String METER_VALUE_GAUGE = "gauge";
|
||||
|
||||
String METER_VALUE_COUNTER = "counter";
|
||||
|
||||
String METER_VALUE_SUMMARY = "summary";
|
||||
|
||||
String METER_VALUE_TIMER = "timer";
|
||||
|
||||
String STATISTIC_VALUE_COUNT = "count";
|
||||
|
||||
String STATISTIC_VALUE_TOTAL = "total";
|
||||
|
||||
String STATISTIC_VALUE_TPS = "tps";
|
||||
|
||||
String STATISTIC_VALUE_MAX = "max";
|
||||
|
||||
String STATISTIC_VALUE_AVERAGE = "average";
|
||||
|
||||
String STATUS_VALUE_ACTIVE = "active";
|
||||
|
||||
String STATUS_VALUE_COMMITTED = "committed";
|
||||
|
||||
String STATUS_VALUE_ROLLBACKED = "rollbacked";
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Value of meter
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public class Measurement {
|
||||
private final Id id;
|
||||
|
||||
private final double timestamp;
|
||||
|
||||
private final double value;
|
||||
|
||||
public Id getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public double getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Measurement(Id id, double timestamp, double value) {
|
||||
this.id = id;
|
||||
this.timestamp = timestamp;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Meter interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Meter {
|
||||
Id getId();
|
||||
|
||||
Iterable<Measurement> measure();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Summary interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Summary extends Meter {
|
||||
default void increase() {
|
||||
increase(1);
|
||||
}
|
||||
|
||||
void increase(long value);
|
||||
|
||||
long total();
|
||||
|
||||
long count();
|
||||
|
||||
double tps();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Default clock implement use system
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public class SystemClock implements Clock {
|
||||
public static final Clock INSTANCE = new SystemClock();
|
||||
|
||||
@Override
|
||||
public double getCurrentMilliseconds() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Default clock implement use system
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Timer extends Meter {
|
||||
void record(long value, TimeUnit unit);
|
||||
|
||||
long count();
|
||||
|
||||
long total();
|
||||
|
||||
long max();
|
||||
|
||||
double average();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.io.Closeable;
|
||||
|
||||
import io.seata.metrics.registry.Registry;
|
||||
|
||||
/**
|
||||
* Exporter interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Exporter extends Closeable {
|
||||
void setRegistry(Registry registry);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.function.Supplier;
|
||||
|
||||
import io.seata.metrics.Counter;
|
||||
import io.seata.metrics.Gauge;
|
||||
import io.seata.metrics.Id;
|
||||
import io.seata.metrics.Measurement;
|
||||
import io.seata.metrics.Summary;
|
||||
import io.seata.metrics.Timer;
|
||||
|
||||
/**
|
||||
* Registry interface for metrics
|
||||
*
|
||||
* @author zhengyangyong
|
||||
*/
|
||||
public interface Registry {
|
||||
<T extends Number> Gauge<T> getGauge(Id id, Supplier<T> supplier);
|
||||
|
||||
Counter getCounter(Id id);
|
||||
|
||||
Summary getSummary(Id id);
|
||||
|
||||
Timer getTimer(Id id);
|
||||
|
||||
Iterable<Measurement> measure();
|
||||
}
|
||||
Reference in New Issue
Block a user