This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 1fb408f [type: feature]: add a part of metrics in agent (#2920)
1fb408f is described below
commit 1fb408f593243df8d3cec193b915ba1f5912c866
Author: YuI <[email protected]>
AuthorDate: Tue Feb 22 16:55:18 2022 +0800
[type: feature]: add a part of metrics in agent (#2920)
* [type: modify]: remove tag of big object in trace.
* [type: feature]: add a part of metrics in agent
* [type: modify]: delete test code.
* [type: modify]: modify shenyu-agent-plugin-metrics-prometheus's module
pom.xml.
Co-authored-by: 艺铭 <[email protected]>
---
.../shenyu/agent/api/config/MetricsConfig.java} | 8 +--
.../agent/core/utils/ShenyuAgentConfigUtils.java | 7 ++-
.../metrics/api/MetricsRecorderRegistry.java | 2 +-
.../metrics/api/constant/MetricsConstant.java | 27 ++++++++--
.../common/factory/MetricsRecorderPool.java | 12 ++---
.../shenyu-agent-plugin-metrics-prometheus/pom.xml | 13 +++++
...ler.java => PrometheusDividePluginHandler.java} | 19 +++++--
.../handler/PrometheusGlobalPluginHandler.java | 14 +++++
.../prometheus/recorder/CounterRecorder.java | 2 +-
.../metrics/prometheus/recorder/GaugeRecorder.java | 2 +-
.../prometheus/recorder/HistogramRecorder.java | 2 +-
.../recorder/MetricsRecorderFactory.java | 2 +-
.../prometheus/recorder/SummaryRecorder.java | 2 +-
.../PrometheusMetricsRecorderRegistry.java | 2 +-
.../shenyu-agent-plugin-tracing-jaeger/pom.xml | 8 +++
.../tracing/jaeger/constant/JaegerConstants.java | 63 ----------------------
.../jaeger/handler/JaegerGlobalPluginHandler.java | 17 +++---
.../jaeger/handler/JaegerPluginCommonHandler.java | 12 ++---
.../tracing/jaeger/span/JaegerErrorSpan.java | 8 +--
.../tracing/jaeger/span/JaegerSpanManager.java | 4 +-
.../src/main/resources/conf/metrics-meta.yaml | 16 +++++-
.../src/main/resources/conf/metrics-point.yaml | 8 ++-
.../src/main/resources/conf/shenyu-agent.yaml | 8 +--
23 files changed, 141 insertions(+), 117 deletions(-)
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/config/Metrics.java
b/shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/config/MetricsConfig.java
similarity index 97%
rename from
shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/config/Metrics.java
rename to
shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/config/MetricsConfig.java
index e9ef94b..4428a23 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/config/Metrics.java
+++
b/shenyu-agent/shenyu-agent-api/src/main/java/org/apache/shenyu/agent/api/config/MetricsConfig.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.agent.plugin.metrics.api.config;
+package org.apache.shenyu.agent.api.config;
import java.util.List;
import java.util.Properties;
@@ -23,10 +23,10 @@ import java.util.Properties;
/**
* The type Metrics.
*/
-public class Metrics {
-
+public class MetricsConfig {
+
private List<Metric> metrics;
-
+
/**
* Gets metrics.
*
diff --git
a/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/utils/ShenyuAgentConfigUtils.java
b/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/utils/ShenyuAgentConfigUtils.java
index 52a4850..f1cfd68 100644
---
a/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/utils/ShenyuAgentConfigUtils.java
+++
b/shenyu-agent/shenyu-agent-core/src/main/java/org/apache/shenyu/agent/core/utils/ShenyuAgentConfigUtils.java
@@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -44,7 +45,11 @@ public final class ShenyuAgentConfigUtils {
*/
public static Set<String> getSupports() {
Map<String, List<String>> supports = getConfig().getSupports();
- return
supports.values().stream().flatMap(Collection::stream).filter(StringUtils::isNoneEmpty).collect(Collectors.toSet());
+ return supports.values().stream()
+ .filter(Objects::nonNull)
+ .flatMap(Collection::stream)
+ .filter(StringUtils::isNoneEmpty)
+ .collect(Collectors.toSet());
}
/**
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/MetricsRecorderRegistry.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/MetricsRecorderRegistry.java
index 9d0cf7f..f74719b 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/MetricsRecorderRegistry.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/MetricsRecorderRegistry.java
@@ -17,7 +17,7 @@
package org.apache.shenyu.agent.plugin.metrics.api;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import org.apache.shenyu.spi.SPI;
import java.util.Optional;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/constant/MetricsConstant.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/constant/MetricsConstant.java
index 0da958d..97ea47c 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/constant/MetricsConstant.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-api/src/main/java/org/apache/shenyu/agent/plugin/metrics/api/constant/MetricsConstant.java
@@ -21,15 +21,32 @@ package org.apache.shenyu.agent.plugin.metrics.api.constant;
* The type Metrics constant.
*/
public final class MetricsConstant {
-
+
+ /**
+ * The constant PROMETHEUS.
+ */
+ public static final String PROMETHEUS = "prometheus";
+
/**
* The constant REQUEST_TOTAL.
*/
public static final String REQUEST_TOTAL = "shenyu_request_total";
-
+
/**
- * The constant PROMETHEUS.
+ * The constant REQUEST_THROW_TOTAL.
*/
- public static final String PROMETHEUS = "prometheus";
-
+ public static final String REQUEST_THROW_TOTAL =
"shenyu_request_throw_total";
+
+ /**
+ * The constant REQUEST_THROW_TOTAL.
+ */
+ public static final String HTTP_REQUEST_TOTAL =
"shenyu_http_request_total";
+
+ /**
+ * The constant SHENYU_REQUEST_UNDONE.
+ */
+ public static final String SHENYU_REQUEST_UNDONE = "shenyu_request_undone";
+
+
+
}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-common/src/main/java/org/apache/shenyu/agent/plugin/metrics/common/factory/MetricsRecorderPool.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-common/src/main/java/org/apache/shenyu/agent/plugin/metrics/common/factory/MetricsRecorderPool.java
index 0a1b05a..a1070ac 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-common/src/main/java/org/apache/shenyu/agent/plugin/metrics/common/factory/MetricsRecorderPool.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-common/src/main/java/org/apache/shenyu/agent/plugin/metrics/common/factory/MetricsRecorderPool.java
@@ -23,8 +23,8 @@ import
org.apache.shenyu.agent.core.utils.ShenyuAgentConfigUtils;
import org.apache.shenyu.agent.core.yaml.ShenyuYamlEngine;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorderRegistry;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,14 +51,14 @@ public class MetricsRecorderPool {
* Init.
*/
public static void init() {
- Metrics metrics = null;
+ MetricsConfig metricsConfig = null;
try {
- metrics =
ShenyuYamlEngine.unmarshal(ShenyuAgentLocator.locatorConf("metrics-meta.yaml"),
Metrics.class);
+ metricsConfig =
ShenyuYamlEngine.unmarshal(ShenyuAgentLocator.locatorConf("metrics-meta.yaml"),
MetricsConfig.class);
} catch (IOException e) {
LOG.error("Exception loader metrics meta data config is", e);
}
- if (Objects.nonNull(metrics) && !metrics.getMetrics().isEmpty()) {
- List<Metric> metricList = metrics.getMetrics();
+ if (Objects.nonNull(metricsConfig) &&
!metricsConfig.getMetrics().isEmpty()) {
+ List<Metric> metricList = metricsConfig.getMetrics();
Collection<MetricsRecorderRegistry> registryList =
SPILoader.loadList(MetricsRecorderRegistry.class);
Set<String> supports = ShenyuAgentConfigUtils.getSupports();
for (Metric metric : metricList) {
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/pom.xml
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/pom.xml
index 17c920b..0ab5dc5 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/pom.xml
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/pom.xml
@@ -33,26 +33,39 @@
<artifactId>shenyu-agent-plugin-metrics-api</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-agent-plugin-metrics-common</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-web</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
+
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>${prometheus.version}</version>
</dependency>
+
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>${prometheus.version}</version>
</dependency>
+
<dependency>
<groupId>io.prometheus.jmx</groupId>
<artifactId>collector</artifactId>
<version>${prometheus.jmx.version}</version>
</dependency>
+
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_httpserver</artifactId>
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusDividePluginHandler.java
similarity index 64%
copy from
shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
copy to
shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusDividePluginHandler.java
index 6b95512..cf45a71 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusDividePluginHandler.java
@@ -20,19 +20,30 @@ package
org.apache.shenyu.agent.plugin.metrics.prometheus.handler;
import org.apache.shenyu.agent.api.entity.MethodResult;
import org.apache.shenyu.agent.api.entity.TargetObject;
import org.apache.shenyu.agent.api.handler.InstanceMethodHandler;
-import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
import org.apache.shenyu.agent.plugin.metrics.api.constant.MetricsConstant;
import
org.apache.shenyu.agent.plugin.metrics.common.factory.MetricsRecorderPool;
+import org.springframework.web.server.ServerWebExchange;
import java.lang.reflect.Method;
/**
- * The type metrics prometheus global plugin handler.
+ * The type metrics prometheus divide plugin handler.
*/
-public final class PrometheusGlobalPluginHandler implements
InstanceMethodHandler {
+public class PrometheusDividePluginHandler implements InstanceMethodHandler {
@Override
public void before(final TargetObject target, final Method method, final
Object[] args, final MethodResult result) {
- MetricsRecorderPool.get(MetricsConstant.REQUEST_TOTAL,
MetricsConstant.PROMETHEUS).ifPresent(MetricsRecorder::inc);
+ final ServerWebExchange exchange = (ServerWebExchange) args[0];
+ final String path = exchange.getRequest().getURI().getPath();
+ final String methodValue = exchange.getRequest().getMethodValue();
+
+ MetricsRecorderPool.get(MetricsConstant.HTTP_REQUEST_TOTAL,
MetricsConstant.PROMETHEUS)
+ .ifPresent(metricsRecorder -> metricsRecorder.inc(path,
methodValue));
}
+
+ @Override
+ public Object after(final TargetObject target, final Method method, final
Object[] args, final MethodResult methodResult) {
+ return methodResult.getResult();
+ }
+
}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
index 6b95512..9f7fd33 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/handler/PrometheusGlobalPluginHandler.java
@@ -34,5 +34,19 @@ public final class PrometheusGlobalPluginHandler implements
InstanceMethodHandle
@Override
public void before(final TargetObject target, final Method method, final
Object[] args, final MethodResult result) {
MetricsRecorderPool.get(MetricsConstant.REQUEST_TOTAL,
MetricsConstant.PROMETHEUS).ifPresent(MetricsRecorder::inc);
+ MetricsRecorderPool.get(MetricsConstant.SHENYU_REQUEST_UNDONE,
MetricsConstant.PROMETHEUS).ifPresent(MetricsRecorder::inc);
}
+
+ @Override
+ public Object after(final TargetObject target, final Method method, final
Object[] args, final MethodResult methodResult) {
+ MetricsRecorderPool.get(MetricsConstant.SHENYU_REQUEST_UNDONE,
MetricsConstant.PROMETHEUS).ifPresent(MetricsRecorder::dec);
+ return methodResult.getResult();
+ }
+
+ @Override
+ public void onThrowing(final TargetObject target, final Method method,
final Object[] args, final Throwable throwable) {
+ MetricsRecorderPool.get(MetricsConstant.REQUEST_THROW_TOTAL,
MetricsConstant.PROMETHEUS).ifPresent(MetricsRecorder::inc);
+ MetricsRecorderPool.get(MetricsConstant.SHENYU_REQUEST_UNDONE,
MetricsConstant.PROMETHEUS).ifPresent(MetricsRecorder::dec);
+ }
+
}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/CounterRecorder.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/CounterRecorder.java
index a09b808..70f4048 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/CounterRecorder.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/CounterRecorder.java
@@ -19,7 +19,7 @@ package
org.apache.shenyu.agent.plugin.metrics.prometheus.recorder;
import io.prometheus.client.Counter;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import java.util.Objects;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/GaugeRecorder.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/GaugeRecorder.java
index 6d4f2ed..bf7ed5a 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/GaugeRecorder.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/GaugeRecorder.java
@@ -19,7 +19,7 @@ package
org.apache.shenyu.agent.plugin.metrics.prometheus.recorder;
import io.prometheus.client.Gauge;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import java.util.Objects;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/HistogramRecorder.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/HistogramRecorder.java
index 57811cb..f5c2302 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/HistogramRecorder.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/HistogramRecorder.java
@@ -19,7 +19,7 @@ package
org.apache.shenyu.agent.plugin.metrics.prometheus.recorder;
import io.prometheus.client.Histogram;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import java.util.Objects;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/MetricsRecorderFactory.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/MetricsRecorderFactory.java
index 306d150..21c114d 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/MetricsRecorderFactory.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/MetricsRecorderFactory.java
@@ -18,7 +18,7 @@
package org.apache.shenyu.agent.plugin.metrics.prometheus.recorder;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import org.apache.shenyu.agent.plugin.metrics.api.enums.MetricsType;
import java.util.Optional;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/SummaryRecorder.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/SummaryRecorder.java
index 7e65028..119244a 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/SummaryRecorder.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/recorder/SummaryRecorder.java
@@ -19,7 +19,7 @@ package
org.apache.shenyu.agent.plugin.metrics.prometheus.recorder;
import io.prometheus.client.Summary;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import java.util.Objects;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/registry/PrometheusMetricsRecorderRegistry.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/registry/PrometheusMetricsRecorderRegistry.java
index b13ec46..db490aa 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/registry/PrometheusMetricsRecorderRegistry.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-metrics/shenyu-agent-plugin-metrics-prometheus/src/main/java/org/apache/shenyu/agent/plugin/metrics/prometheus/registry/PrometheusMetricsRecorderRegistry.java
@@ -19,7 +19,7 @@ package
org.apache.shenyu.agent.plugin.metrics.prometheus.registry;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorder;
import org.apache.shenyu.agent.plugin.metrics.api.MetricsRecorderRegistry;
-import org.apache.shenyu.agent.plugin.metrics.api.config.Metrics.Metric;
+import org.apache.shenyu.agent.api.config.MetricsConfig.Metric;
import org.apache.shenyu.agent.plugin.metrics.api.constant.MetricsConstant;
import
org.apache.shenyu.agent.plugin.metrics.prometheus.recorder.MetricsRecorderFactory;
import org.apache.shenyu.spi.Join;
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/pom.xml
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/pom.xml
index 8dcf270..031f129 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/pom.xml
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/pom.xml
@@ -50,12 +50,20 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-web</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-agent-plugin-tracing-common</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/constant/JaegerConstants.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/constant/JaegerConstants.java
deleted file mode 100644
index 9928036..0000000
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/constant/JaegerConstants.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.shenyu.agent.plugin.tracing.jaeger.constant;
-
-/**
- * The type Jaeger constants.
- */
-public final class JaegerConstants {
-
- /**
- * The constant ROOT_SPAN.
- */
- public static final String ROOT_SPAN = "/shenyu/root";
-
- /**
- * The constant NAME.
- */
- public static final String NAME = "shenyu";
-
- public static final String RESPONSE_SPAN = "/shenyu/root";
-
- /**
- * The type Error log tags.
- */
- public static final class ErrorLogTags {
-
- /**
- * The constant EVENT.
- */
- public static final String EVENT = "event";
-
- /**
- * The constant EVENT_ERROR_TYPE.
- */
- public static final String EVENT_ERROR_TYPE = "error";
-
- /**
- * The constant ERROR_KIND.
- */
- public static final String ERROR_KIND = "error.kind";
-
- /**
- * The constant MESSAGE.
- */
- public static final String MESSAGE = "message";
- }
-
-}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
index 8a3f79a..95cab3c 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerGlobalPluginHandler.java
@@ -22,7 +22,7 @@ import io.opentracing.tag.Tags;
import org.apache.shenyu.agent.api.entity.MethodResult;
import org.apache.shenyu.agent.api.entity.TargetObject;
import org.apache.shenyu.agent.api.handler.InstanceMethodHandler;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
+import org.apache.shenyu.agent.plugin.tracing.common.constant.TracingConstants;
import org.apache.shenyu.agent.plugin.tracing.jaeger.span.JaegerSpanManager;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@@ -41,16 +41,15 @@ public final class JaegerGlobalPluginHandler implements
InstanceMethodHandler {
public void before(final TargetObject target, final Method method, final
Object[] args, final MethodResult result) {
final ServerWebExchange exchange = (ServerWebExchange) args[0];
final JaegerSpanManager jaegerSpanManager = (JaegerSpanManager)
exchange.getAttributes()
- .getOrDefault(JaegerConstants.ROOT_SPAN, new
JaegerSpanManager());
+ .getOrDefault(TracingConstants.SHENYU_AGENT, new
JaegerSpanManager());
Map<String, String> tagMap = new HashMap<>(4);
- tagMap.put(Tags.COMPONENT.getKey(), JaegerConstants.NAME);
- tagMap.put(Tags.HTTP_URL.getKey(),
exchange.getRequest().getURI().toString());
+ tagMap.put(TracingConstants.COMPONENT, TracingConstants.NAME);
Optional.ofNullable(exchange.getRequest().getMethod())
- .ifPresent(v -> tagMap.put(Tags.HTTP_METHOD.getKey(),
v.toString()));
+ .ifPresent(v -> tagMap.put(Tags.HTTP_METHOD.getKey(),
v.toString()));
- Span span = jaegerSpanManager.add(JaegerConstants.ROOT_SPAN, tagMap);
- exchange.getAttributes().put(JaegerConstants.RESPONSE_SPAN,
jaegerSpanManager);
+ Span span = jaegerSpanManager.add(TracingConstants.ROOT_SPAN, tagMap);
+ exchange.getAttributes().put(TracingConstants.SHENYU_AGENT,
jaegerSpanManager);
target.setContext(span);
}
@@ -59,7 +58,7 @@ public final class JaegerGlobalPluginHandler implements
InstanceMethodHandler {
Object result = methodResult.getResult();
Span span = (Span) target.getContext();
ServerWebExchange exchange = (ServerWebExchange) args[0];
- JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+ JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(TracingConstants.ROOT_SPAN);
if (result instanceof Mono) {
return ((Mono) result).doFinally(s -> {
@@ -76,7 +75,7 @@ public final class JaegerGlobalPluginHandler implements
InstanceMethodHandler {
Span span = (Span) target.getContext();
ServerWebExchange exchange = (ServerWebExchange) args[0];
- JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+ JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(TracingConstants.ROOT_SPAN);
manager.error(span, exchange, throwable);
}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java
index 3a9560f..1184148 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/handler/JaegerPluginCommonHandler.java
@@ -22,7 +22,7 @@ import io.opentracing.tag.Tags;
import org.apache.shenyu.agent.api.entity.MethodResult;
import org.apache.shenyu.agent.api.entity.TargetObject;
import org.apache.shenyu.agent.api.handler.InstanceMethodHandler;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
+import org.apache.shenyu.agent.plugin.tracing.common.constant.TracingConstants;
import org.apache.shenyu.agent.plugin.tracing.jaeger.span.JaegerSpanManager;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@@ -40,13 +40,13 @@ public final class JaegerPluginCommonHandler implements
InstanceMethodHandler {
public void before(final TargetObject target, final Method method, final
Object[] args, final MethodResult result) {
final ServerWebExchange exchange = (ServerWebExchange) args[0];
final JaegerSpanManager jaegerSpanManager = (JaegerSpanManager)
exchange.getAttributes()
- .getOrDefault(JaegerConstants.ROOT_SPAN, new
JaegerSpanManager());
+ .getOrDefault(TracingConstants.ROOT_SPAN, new
JaegerSpanManager());
Map<String, String> tagMap = new HashMap<>(2, 1);
- tagMap.put(Tags.COMPONENT.getKey(), JaegerConstants.NAME);
+ tagMap.put(Tags.COMPONENT.getKey(), TracingConstants.NAME);
Span span =
jaegerSpanManager.add(method.getDeclaringClass().getSimpleName(), tagMap);
- exchange.getAttributes().put(JaegerConstants.RESPONSE_SPAN,
jaegerSpanManager);
+ exchange.getAttributes().put(TracingConstants.ROOT_SPAN,
jaegerSpanManager);
target.setContext(span);
}
@@ -55,7 +55,7 @@ public final class JaegerPluginCommonHandler implements
InstanceMethodHandler {
Object result = methodResult.getResult();
Span span = (Span) target.getContext();
ServerWebExchange exchange = (ServerWebExchange) args[0];
- JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+ JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(TracingConstants.ROOT_SPAN);
if (result instanceof Mono) {
return ((Mono) result).doFinally(s -> {
@@ -72,7 +72,7 @@ public final class JaegerPluginCommonHandler implements
InstanceMethodHandler {
Span span = (Span) target.getContext();
ServerWebExchange exchange = (ServerWebExchange) args[0];
- JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(JaegerConstants.ROOT_SPAN);
+ JaegerSpanManager manager = (JaegerSpanManager)
exchange.getAttributes().get(TracingConstants.ROOT_SPAN);
manager.error(span, exchange, throwable);
}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
index b51fd3c..7a60b03 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerErrorSpan.java
@@ -19,7 +19,7 @@ package org.apache.shenyu.agent.plugin.tracing.jaeger.span;
import io.opentracing.Span;
import io.opentracing.tag.Tags;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
+import org.apache.shenyu.agent.plugin.tracing.common.constant.TracingConstants;
import java.util.HashMap;
import java.util.Map;
@@ -41,9 +41,9 @@ public final class JaegerErrorSpan {
private static Map<String, ?> getReason(final Throwable cause) {
Map<String, String> result = new HashMap<>(3, 1);
- result.put(JaegerConstants.ErrorLogTags.EVENT,
JaegerConstants.ErrorLogTags.EVENT_ERROR_TYPE);
- result.put(JaegerConstants.ErrorLogTags.ERROR_KIND,
cause.getClass().getName());
- result.put(JaegerConstants.ErrorLogTags.MESSAGE, cause.getMessage());
+ result.put(TracingConstants.ErrorLogTags.EVENT,
TracingConstants.ErrorLogTags.EVENT_ERROR_TYPE);
+ result.put(TracingConstants.ErrorLogTags.ERROR_KIND,
cause.getClass().getName());
+ result.put(TracingConstants.ErrorLogTags.MESSAGE, cause.getMessage());
return result;
}
}
diff --git
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java
index 0a65df2..5065b6e 100644
---
a/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java
+++
b/shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/shenyu-agent-plugin-tracing-jaeger/src/main/java/org/apache/shenyu/agent/plugin/tracing/jaeger/span/JaegerSpanManager.java
@@ -21,7 +21,7 @@ import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
-import org.apache.shenyu.agent.plugin.tracing.jaeger.constant.JaegerConstants;
+import org.apache.shenyu.agent.plugin.tracing.common.constant.TracingConstants;
import org.springframework.web.server.ServerWebExchange;
import java.util.LinkedList;
@@ -84,7 +84,7 @@ public class JaegerSpanManager {
span.finish();
if (count.decrementAndGet() == 0) {
scopeList.forEach(Scope::close);
- exchange.getAttributes().remove(JaegerConstants.RESPONSE_SPAN);
+ exchange.getAttributes().remove(TracingConstants.SHENYU_AGENT);
}
}
diff --git
a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-meta.yaml
b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-meta.yaml
index 1db5225..77e3fce 100644
--- a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-meta.yaml
+++ b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-meta.yaml
@@ -16,7 +16,19 @@
#
metrics:
- - name: shenyu_request_total
+ - name: shenyu_request_total
type: counter
- help: the shenyu gateway request total
+ help: ShenYu gateway request total.
+ - name: shenyu_request_throw_total
+ type: counter
+ help: ShenYu gateway request total when an exception occurs.
+ - name: shenyu_http_request_total
+ type: counter
+ labelNames:
+ - path
+ - method
+ help: ShenYu gateway request total of http.
+ - name: shenyu_request_undone
+ type: gauge
+ help: ShenYu gateway request is not completed.
diff --git
a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-point.yaml
b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-point.yaml
index dee3fb6..c8fe705 100644
--- a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-point.yaml
+++ b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/metrics-point.yaml
@@ -23,4 +23,10 @@ pointCuts:
handlers:
prometheus:
-
org.apache.shenyu.agent.plugin.metrics.prometheus.handler.PrometheusGlobalPluginHandler
-
\ No newline at end of file
+ - targetClass: org.apache.shenyu.plugin.divide.DividePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ prometheus:
+ -
org.apache.shenyu.agent.plugin.metrics.prometheus.handler.PrometheusDividePluginHandler
\ No newline at end of file
diff --git
a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/shenyu-agent.yaml
b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/shenyu-agent.yaml
index aad51ee..669c135 100644
--- a/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/shenyu-agent.yaml
+++ b/shenyu-dist/shenyu-agent-dist/src/main/resources/conf/shenyu-agent.yaml
@@ -18,13 +18,13 @@
appName: shenyu-agent
supports:
tracing:
- - jaeger
+# - jaeger
# - opentelemetry
# - zipkin
metrics:
- -
+# - prometheus
logging:
- - rocketmq
+# - rocketmq
plugins:
tracing:
@@ -53,6 +53,8 @@ plugins:
host: "localhost"
port: 8081
props:
+ jvm_enabled: false
+ jmx_config:
logging:
elasticSearch:
host: "localhost"